Skip to content

Commit 01c3598

Browse files
committed
black format, and pre-commit
1 parent d790030 commit 01c3598

File tree

1 file changed

+27
-18
lines changed

1 file changed

+27
-18
lines changed

adafruit_displayio_layout/layouts/grid_layout.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
__version__ = "0.0.0-auto.0"
2929
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_Layout.git"
3030

31+
3132
class GridLayout(displayio.Group):
3233

3334
"""
@@ -36,16 +37,8 @@ class GridLayout(displayio.Group):
3637
:param int x: x location the layout should be placed
3738
:param int y: y location the layout should be placed
3839
"""
39-
def __init__(
40-
self,
41-
x,
42-
y,
43-
width,
44-
height,
45-
grid_size,
46-
child_padding,
47-
max_children=4
48-
):
40+
41+
def __init__(self, x, y, width, height, grid_size, child_padding, max_children=4):
4942
super().__init__(x=x, y=y, max_size=max_children)
5043
self.x = x
5144
self.y = y
@@ -68,21 +61,37 @@ def _layout_sub_views(self):
6861
button_size_x = sub_view["view_grid_size"][0]
6962
button_size_y = sub_view["view_grid_size"][1]
7063

71-
print("setting width to: {}".format(
72-
int(button_size_x * self._width / grid_size_x) - 2 * self.child_padding))
73-
sub_view["view"].width = int(button_size_x * self._width / grid_size_x) - 2 * self.child_padding
74-
sub_view["view"].height = int(button_size_y * self._height / grid_size_y) - 2 * self.child_padding
75-
76-
sub_view["view"].x = int(grid_position_x * self._width / grid_size_x) + self.child_padding
77-
sub_view["view"].y = int(grid_position_y * self._height / grid_size_y) + self.child_padding
64+
print(
65+
"setting width to: {}".format(
66+
int(button_size_x * self._width / grid_size_x)
67+
- 2 * self.child_padding
68+
)
69+
)
70+
sub_view["view"].width = (
71+
int(button_size_x * self._width / grid_size_x)
72+
- 2 * self.child_padding
73+
)
74+
sub_view["view"].height = (
75+
int(button_size_y * self._height / grid_size_y)
76+
- 2 * self.child_padding
77+
)
78+
79+
sub_view["view"].x = (
80+
int(grid_position_x * self._width / grid_size_x)
81+
+ self.child_padding
82+
)
83+
sub_view["view"].y = (
84+
int(grid_position_y * self._height / grid_size_y)
85+
+ self.child_padding
86+
)
7887

7988
self.append(sub_view["view"])
8089

8190
def add_sub_view(self, new_view, grid_position, view_grid_size):
8291
sub_view_obj = {
8392
"view": new_view,
8493
"grid_position": grid_position,
85-
"view_grid_size": view_grid_size
94+
"view_grid_size": view_grid_size,
8695
}
8796
self._sub_views.append(sub_view_obj)
8897
self._layout_sub_views()

0 commit comments

Comments
 (0)