Skip to content

fix for content elements that dont allow setting width and height #42

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 1 commit into from
Jul 24, 2021
Merged
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
23 changes: 14 additions & 9 deletions adafruit_displayio_layout/layouts/grid_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,20 @@ def _layout_cells(self):
),
)
else:
# try width and height properties.
cell["content"].width = (
int(button_size_x * self._width / grid_size_x)
- 2 * self.cell_padding
)
cell["content"].height = (
int(button_size_y * self._height / grid_size_y)
- 2 * self.cell_padding
)
try:
# try width and height properties.
cell["content"].width = (
int(button_size_x * self._width / grid_size_x)
- 2 * self.cell_padding
)
cell["content"].height = (
int(button_size_y * self._height / grid_size_y)
- 2 * self.cell_padding
)
except AttributeError:
# This element does not allow setting width and height.
# No problem, we'll use whatever size it already is.
pass

cell["content"].x = (
int(grid_position_x * self._width / grid_size_x) + self.cell_padding
Expand Down