1
0
Fork 0

widgets: Further compact some of the internal representations

Many widgets adopted the _im(mutable) idiom to allow us to reduce the
RAM overhead of each widget. Where the immutable data considers entirely
of integers smaller than 256 then we can push this just a little further
by switching from a tuple to a bytes.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-06-20 17:08:39 +01:00
parent 9099c2398e
commit ae0d59dbe3

View file

@ -305,7 +305,7 @@ class Checkbox():
class GfxButton(): class GfxButton():
"""A button with a graphical icon.""" """A button with a graphical icon."""
def __init__(self, x, y, gfx): def __init__(self, x, y, gfx):
self._im = (x, y) self._im = bytes((x, y))
self.gfx = gfx self.gfx = gfx
def draw(self): def draw(self):
@ -410,7 +410,7 @@ class Spinner():
widget and requires 60x120 px. widget and requires 60x120 px.
""" """
def __init__(self, x, y, mn, mx, field=1): def __init__(self, x, y, mn, mx, field=1):
self._im = (x, y, mn, mx, field) self._im = bytes((x, y, mn, mx, field))
self.value = mn self.value = mn
def draw(self): def draw(self):