Skip to content

Commit

Permalink
[fix] screen errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsimonart committed May 13, 2018
1 parent 8223e3e commit e6eff4b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion GLM/source/libs/pluginbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .templater import Templater
from .imageloader import load_image

VERSION = "0.11.0"
VERSION = "0.11.1"

class PluginBase(ABC):
def __init__(self, start, *args):
Expand Down
50 changes: 46 additions & 4 deletions GLM/source/libs/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def set_fps(self, fps):
def add(self, element, name="default", **kwargs):
"""
Add a new Image to the childs.
Returns true for success
Keyword arguments:
element -- Image
Expand All @@ -85,6 +86,8 @@ def add(self, element, name="default", **kwargs):
self.__childs.append(
(element.screen_data(), x, y, refresh, mode, name)
)
return True
return False

def insert(self, position, element, name="default", **kwargs):
"""Inserts a child to the screen before 'position'
Expand All @@ -108,12 +111,47 @@ def insert(self, position, element, name="default", **kwargs):
if type(position) == str:
for i, child in enumerate(self.__childs):
if position in child[5]:
self.__childs.insert(i, element)
self.__childs.insert(i, (
element.screen_data(), x, y, refresh, mode, name)
)
return True
elif type(position) == int:
self.__childs.insert(position, element)
self.__childs.insert(position, (
element.screen_data(), x, y, refresh, mode, name)
)
return True
return False

def replace(self, position, element, name='default', **kwargs):
"""Replaces a child at index 'position'
Returns True for success
Keyword arguments:
position -- Index or name to insert before
element -- Image
x -- x paste location (default 0)
y -- y paste location (default 0)
refresh -- blank Image after refresh (default True)
mode -- paste mode [Image.paste()] (default "fill")
name -- name (default "Child")
"""
x = kwargs.get('x', 0)
y = kwargs.get('y', 0)
refresh = kwargs.get('refresh', False)
mode = kwargs.get('mode', 'fill')
if self.check_type(element):
if type(position) == str:
for i, child in enumerate(self.__childs):
if position in child[5]:
self.__childs[i] = (
element.screen_data(), x, y, refresh, mode, name
)
return True
elif type(position) == int:
self.__childs[position] = (
element.screen_data(), x, y, refresh, mode, name
)
return True
return False

def remove(self, *names):
Expand Down Expand Up @@ -142,7 +180,6 @@ def remove_id(self, id_):
level=0
)


def remove_all(self):
"""Remove all childs"""
number_of_childs = len(self.__childs)
Expand Down Expand Up @@ -197,7 +234,12 @@ def __str__(self):
return string

def __getitem__(self, index):
return self.__childs[index]
if type(index) == int:
return self.__childs[index]
elif type(index) == str:
for child in self.__childs:
if index == child[5]:
return child

def show_gui(self):
"""
Expand Down

0 comments on commit e6eff4b

Please sign in to comment.