diff --git a/adafruit_displayio_layout/layouts/grid_layout.py b/adafruit_displayio_layout/layouts/grid_layout.py index a99d2dc..807774c 100644 --- a/adafruit_displayio_layout/layouts/grid_layout.py +++ b/adafruit_displayio_layout/layouts/grid_layout.py @@ -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