From bf06df8764cca5be2c4c49c5830ca3119a13b826 Mon Sep 17 00:00:00 2001 From: Chaitanya Lakhchaura <90706514+ZenithFlux@users.noreply.github.com> Date: Sat, 8 Apr 2023 09:46:36 +0530 Subject: [PATCH] iconphoto method fixed --- customtkinter/windows/ctk_tk.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/customtkinter/windows/ctk_tk.py b/customtkinter/windows/ctk_tk.py index cc3c940..367b6c7 100644 --- a/customtkinter/windows/ctk_tk.py +++ b/customtkinter/windows/ctk_tk.py @@ -57,6 +57,7 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass): self.title("CTk") # indicator variables + self._iconphoto_method_called = False # indicates if wm_iconphoto method got called self._iconbitmap_method_called = False # indicates if wm_iconbitmap method got called self._state_before_windows_set_titlebar_color = None self._window_exists = False # indicates if the window is already shown through update() or mainloop() after init @@ -229,10 +230,16 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass): self._iconbitmap_method_called = True super().wm_iconbitmap(bitmap, default) + def wm_iconphoto(self, default=False, *args): + self._iconphoto_method_called = True + super().wm_iconphoto(default, *args) + + iconphoto = wm_iconphoto + def _windows_set_titlebar_icon(self): try: # if not the user already called iconbitmap method, set icon - if not self._iconbitmap_method_called: + if not (self._iconbitmap_method_called or self._iconphoto_method_called): customtkinter_directory = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) self.iconbitmap(os.path.join(customtkinter_directory, "assets", "icons", "CustomTkinter_icon_Windows.ico")) except Exception: