@@ -50,33 +50,23 @@ def __init__(self):
5050 if getattr (sys , 'frozen' , False ):
5151 # PyInstaller: bundled data is in sys._MEIPASS
5252 base_dir = sys ._MEIPASS
53+ png_path = os .path .join (base_dir , "alarm_icon7.png" )
5354 else :
5455 base_dir = os .path .normpath (os .path .join (os .path .dirname (os .path .abspath (__file__ )), "../.." ))
56+ png_path = os .path .join (base_dir , "icons" , "alarm_icon7.png" )
5557
56- png_path = os .path .join (base_dir , "alarm_icon7.png" )
57- ico_path = os .path .join (base_dir , "alarm_icon7.ico" )
58-
59- if sys .platform == "win32" :
60- # Windows: prefer .ico (native), fall back to .png via Pillow
61- if os .path .exists (ico_path ):
62- self .iconbitmap (ico_path )
63- elif os .path .exists (png_path ):
64- from PIL import Image , ImageTk
65- img = Image .open (png_path )
66- photo = ImageTk .PhotoImage (img )
67- self .iconphoto (True , photo )
68- self ._icon_ref = photo
58+ if os .path .exists (png_path ):
59+ from PIL import Image , ImageTk
60+ img = Image .open (png_path )
61+ photo = ImageTk .PhotoImage (img )
62+ # True flag applies icon to all future dialogs and taskbar
63+ self .iconphoto (True , photo )
64+ self ._icon_ref = photo
6965 else :
70- # Linux: prefer .png (native for iconphoto), fall back to .ico via Pillow
71- icon_file = png_path if os .path .exists (png_path ) else ico_path
72- if os .path .exists (icon_file ):
73- from PIL import Image , ImageTk
74- img = Image .open (icon_file )
75- photo = ImageTk .PhotoImage (img )
76- self .iconphoto (True , photo )
77- self ._icon_ref = photo
66+ logging .warning (f"Window icon not found at: { png_path } " )
67+
7868 except Exception as e :
79- logging .debug (f"Could not set window icon: { e } " )
69+ logging .error (f"Could not set window icon: { e } " )
8070
8171 # --- UI LAYOUT ---
8272 top_frame = ttk .Frame (self )
0 commit comments