fix PIL Image import error

This commit is contained in:
Tom Schimansky 2022-12-01 09:33:13 +01:00
parent 83dedea59c
commit 482a6e60b7

View File

@ -19,8 +19,8 @@ class CTkImage:
_checked_PIL_import = False
def __init__(self,
light_image: Image.Image = None,
dark_image: Image.Image = None,
light_image: "Image.Image" = None,
dark_image: "Image.Image" = None,
size: Tuple[int, int] = (20, 20)):
if not self._checked_PIL_import:
@ -92,21 +92,21 @@ class CTkImage:
def _get_scaled_size(self, widget_scaling: float) -> Tuple[int, int]:
return round(self._size[0] * widget_scaling), round(self._size[1] * widget_scaling)
def _get_scaled_light_photo_image(self, scaled_size: Tuple[int, int]) -> ImageTk.PhotoImage:
def _get_scaled_light_photo_image(self, scaled_size: Tuple[int, int]) -> "ImageTk.PhotoImage":
if scaled_size in self._scaled_light_photo_images:
return self._scaled_light_photo_images[scaled_size]
else:
self._scaled_light_photo_images[scaled_size] = ImageTk.PhotoImage(self._light_image.resize(scaled_size))
return self._scaled_light_photo_images[scaled_size]
def _get_scaled_dark_photo_image(self, scaled_size: Tuple[int, int]) -> ImageTk.PhotoImage:
def _get_scaled_dark_photo_image(self, scaled_size: Tuple[int, int]) -> "ImageTk.PhotoImage":
if scaled_size in self._scaled_dark_photo_images:
return self._scaled_dark_photo_images[scaled_size]
else:
self._scaled_dark_photo_images[scaled_size] = ImageTk.PhotoImage(self._dark_image.resize(scaled_size))
return self._scaled_dark_photo_images[scaled_size]
def create_scaled_photo_image(self, widget_scaling: float, appearance_mode: str) -> ImageTk.PhotoImage:
def create_scaled_photo_image(self, widget_scaling: float, appearance_mode: str) -> "ImageTk.PhotoImage":
scaled_size = self._get_scaled_size(widget_scaling)
if appearance_mode == "light" and self._light_image is not None: