Skip to content

Commit 25c8b87

Browse files
committed
Pass filename to OnDiskBitmap to avoid closed file problem
1 parent d5aa61d commit 25c8b87

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

adafruit_displayio_layout/widgets/icon_widget.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ def __init__(self, label_text, icon, on_disk=False, **kwargs):
5757
self._icon = icon
5858

5959
if on_disk:
60-
with open(self._icon, "rb") as self._file:
61-
image = OnDiskBitmap(self._file)
62-
tile_grid = TileGrid(
63-
image,
64-
pixel_shader=getattr(image, "pixel_shader", ColorConverter())
65-
# TODO: Once CP6 is no longer supported replace the above line with below.
66-
# tile_grid = TileGrid(image, pixel_shader=image.pixel_shader)
67-
)
60+
image = OnDiskBitmap(self._icon)
61+
tile_grid = TileGrid(image, pixel_shader=image.pixel_shader)
6862
else:
6963
image, palette = adafruit_imageload.load(icon)
7064
tile_grid = TileGrid(image, pixel_shader=palette)

0 commit comments

Comments
 (0)