Skip to content

Remove max_size parameter #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions adafruit_displayio_layout/layouts/grid_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,11 @@ class GridLayout(displayio.Group):
:param int height: Height of the layout in pixels.
:param tuple grid_size: Size in cells as two ints in a tuple e.g. (2, 2)
:param int cell_padding: Extra padding space inside each cell. In pixels.
:param int max_size: (Optional) this will get passed through to the
displayio.Group constructor. If omitted we default to
grid_size width * grid_size height to make room for all (1, 1) sized cells.

"""

# pylint: disable=too-many-arguments
def __init__(self, x, y, width, height, grid_size, cell_padding, max_size=None):
if not max_size:
max_size = grid_size[0] * grid_size[1]
super().__init__(x=x, y=y, max_size=max_size)
def __init__(self, x, y, width, height, grid_size, cell_padding):
super().__init__(x=x, y=y)
self.x = x
self.y = y
self._width = width
Expand Down
2 changes: 1 addition & 1 deletion adafruit_displayio_layout/widgets/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def __init__(
self._line0 = Line(line_x0, line_y0, line_x1, line_y1, color=line_color)
self._line1 = Line(line_x1, line_y1, line_x2, line_y2, color=line_color)

super().__init__(max_size=3)
super().__init__()
# Group elements:
# 0. Line0 - from (x,y) to (x+delta_x, y+delta_y)
# 1. Line1 - horizontal line for text
Expand Down
4 changes: 2 additions & 2 deletions adafruit_displayio_layout/widgets/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Cartesian(Widget):
.. code-block:: python

my_plane= Plane(20, 30) # instance the plane at x=20, y=30
my_group = displayio.Group(max_size=10) # make a group that can hold 10 items
my_group = displayio.Group() # make a group
my_group.append(my_plane) # Add my_plane to the group

#
Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(
**kwargs,
) -> None:

super().__init__(**kwargs, max_size=3)
super().__init__(**kwargs)

self._background_color = background_color

Expand Down
6 changes: 1 addition & 5 deletions adafruit_displayio_layout/widgets/dial.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,8 @@ def __init__(
value_label_anchor_on_widget=(0.5, 0.5), # default label position on widget
**kwargs,
):

# initialize the Widget superclass (x, y, scale)
super().__init__(**kwargs, max_size=3)
# Define how many graphical elements will be in this group
# using "max_size=XX"
#
super().__init__(**kwargs)
# Group elements for SwitchRoundHorizontal:
# 0. TileGrid holding bitmap with ticks and tick label text
# 1. Value label (optional)
Expand Down
6 changes: 2 additions & 4 deletions adafruit_displayio_layout/widgets/flip_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ def __init__(
cool_down=0.0,
**kwargs,
):

super().__init__(**kwargs, max_size=4)
super().__init__(**kwargs)
# Group elements for the FlipInput.
# 0. The text
# 1. The group holding the temporary scroll bitmap
Expand Down Expand Up @@ -235,8 +234,7 @@ def __init__(
self._update_position() # call Widget superclass function to reposition

self._animation_group = displayio.Group(
max_size=1,
scale=self._font_scale,
scale=self._font_scale
) # holds the animation bitmap
# self._animation_group.x = -1 * left * (1)
# self._animation_group.y = -1 * top * (1)
Expand Down
5 changes: 1 addition & 4 deletions adafruit_displayio_layout/widgets/icon_animated.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ class IconAnimated(IconWidget):
:type anchor_point: Tuple[float,float]
:param int anchored_position: (x,y) pixel value for the location of the anchor_point
:type anchored_position: Tuple[int, int]
:param int max_size: (Optional) this will get passed through to the
displayio.Group constructor. ``max_size`` should be set to the maximum number of
graphical elements that will be held within the Group of this widget.
"""

# pylint: disable=bad-super-call, too-many-instance-attributes, too-many-locals
Expand Down Expand Up @@ -145,7 +142,7 @@ def __init__(
if self.__class__.display is None:
raise ValueError(
"Must initialize class using\n"
"`IconAnimated.init_class(display, max_scale, max_size, max_color_depth)`\n"
"`IconAnimated.init_class(display, max_scale, max_color_depth)`\n"
"prior to instancing IconAnimated widgets."
)

Expand Down
4 changes: 0 additions & 4 deletions adafruit_displayio_layout/widgets/icon_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ class IconWidget(Widget, Control):
:type anchor_point: Tuple[float,float]
:param int anchored_position: (x,y) pixel value for the location of the anchor_point
:type anchored_position: Tuple[int, int]
:param int max_size: (Optional) this will get passed through to the
displayio.Group constructor. ``max_size`` should be set to the maximum number of
graphical elements that will be held within the Group of this widget.

"""

def __init__(self, label_text, icon, on_disk=False, **kwargs):
Expand Down
7 changes: 2 additions & 5 deletions adafruit_displayio_layout/widgets/switch_round.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class SwitchRound(Widget, Control):
.. code-block:: python

my_switch = Switch(20, 30) # instance the switch at x=20, y=30
my_group = displayio.Group(max_size=10) # make a group that can hold 10 items
my_group = displayio.Group() # make a group
my_group.append(my_switch) # Add my_switch to the group

#
Expand Down Expand Up @@ -445,10 +445,7 @@ def __init__(
):

# initialize the Widget superclass (x, y, scale)
super().__init__(x=x, y=y, height=height, width=width, **kwargs, max_size=4)
# Define how many graphical elements will be in this group
# using "max_size=XX"
#
super().__init__(x=x, y=y, height=height, width=width, **kwargs)
# Group elements for SwitchRound:
# 0. switch_roundrect: The switch background
# 1. switch_circle: The switch button
Expand Down
6 changes: 1 addition & 5 deletions adafruit_displayio_layout/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,10 @@ def __init__(
height=None,
anchor_point=None,
anchored_position=None,
**kwargs,
):

super().__init__(x=x, y=y, scale=scale, **kwargs)
super().__init__(x=x, y=y, scale=scale)
# send x,y and scale to Group
# **kwargs should include `max_size`from the subclass implementation
# to define how many graphical elements will be held in the Group that
# makes up this widget
#
# If scale is set > 1, will need to update the Control `touch_boundary`
# to accommodate the larger scale
Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_annotation_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
text="Freeform annotation (display.width, height)",
)

my_group = displayio.Group(max_size=4)
my_group = displayio.Group()
my_group.append(my_switch)
my_group.append(switch_annotation)
my_group.append(switch_annotation_under)
Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_cartesian_advanced_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# Create different Cartesian widgets
my_group = displayio.Group(max_size=10)
my_group = displayio.Group()

car = Cartesian(
x=25,
Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_cartesian_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
font_color=0xFFFFFF, # ticks line color
)

my_group = displayio.Group(max_size=3)
my_group = displayio.Group()
my_group.append(my_plane)
display.show(my_group) # add high level Group to the display

Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_dial_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
tick_label_scale=2.0, # the scale factor for the tick label font
)

my_group = displayio.Group(max_size=1)
my_group = displayio.Group()
my_group.append(my_dial)

display.show(my_group) # add high level Group to the display
Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_flip_input_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
my_flip3.value = "2015" # or set the value based on a string that is in the value_list

# Create the group to display and append the FlipInput widgets
my_group = displayio.Group(max_size=3)
my_group = displayio.Group()
my_group.append(my_flip1)
my_group.append(my_flip2)
my_group.append(my_flip3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from adafruit_displayio_layout.layouts.grid_layout import GridLayout

display = PyGameDisplay(width=320, height=240)
main_group = displayio.Group(max_size=10)
main_group = displayio.Group()
display.show(main_group)

layout = GridLayout(
Expand Down
3 changes: 1 addition & 2 deletions examples/displayio_layout_gridlayout_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
display = board.DISPLAY

# Make the display context
main_group = displayio.Group(max_size=10)
main_group = displayio.Group()
display.show(main_group)

layout = GridLayout(
Expand All @@ -27,7 +27,6 @@
height=100,
grid_size=(2, 2),
cell_padding=8,
max_size=10,
)
_labels = []

Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_icon_animated_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

icons = [icon_zoom, icon_shrink]

main_group = displayio.Group(max_size=2)
main_group = displayio.Group()
main_group.append(icon_zoom)
main_group.append(icon_shrink)

Expand Down
3 changes: 1 addition & 2 deletions examples/displayio_layout_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
display = board.DISPLAY

# Make the display context
main_group = displayio.Group(max_size=10)
main_group = displayio.Group()
display.show(main_group)

layout = GridLayout(
Expand All @@ -29,7 +29,6 @@
height=100,
grid_size=(2, 2),
cell_padding=8,
max_size=10,
)
_labels = []

Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_switch_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
# the switch anchored_position is 10 pixels from the display
# lower right corner

my_group = displayio.Group(max_size=8)
my_group = displayio.Group()
my_group.append(my_switch)
my_group.append(my_switch2)
my_group.append(my_switch3)
Expand Down
2 changes: 1 addition & 1 deletion examples/displayio_layout_switch_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
my_switch = Switch(20, 30)


my_group = displayio.Group(max_size=1)
my_group = displayio.Group()
my_group.append(my_switch)

# Add my_group to the display
Expand Down