@@ -666,25 +666,41 @@ def set_status(self, text, style="secondary", duration=3000):
666666 root .geometry ("1000x650" ) # Set initial window size for the expanded layout
667667 root .minsize (950 , 600 ) # Set minimum window size to prevent cramping
668668
669- # Set application icon with enhanced error handling
669+ # Set application icon with PyInstaller compatibility
670+ def get_resource_path (relative_path ):
671+ """Get absolute path to resource, works for dev and for PyInstaller"""
672+ try :
673+ # PyInstaller creates a temp folder and stores path in _MEIPASS
674+ base_path = sys ._MEIPASS
675+ except Exception :
676+ base_path = os .path .abspath ("." )
677+ return os .path .join (base_path , relative_path )
678+
670679 try :
671680 if sys .platform .startswith ("win" ):
672- icon_path = "icon.ico"
681+ icon_path = get_resource_path ( "icon.ico" )
673682 if os .path .exists (icon_path ):
674- # Use absolute path and try multiple methods for better compatibility
675- abs_icon_path = os .path .abspath (icon_path )
676- root .iconbitmap (abs_icon_path )
677- # Also try the wm method for better ttkbootstrap compatibility
678- root .wm_iconbitmap (abs_icon_path )
683+ root .iconbitmap (icon_path )
684+ root .wm_iconbitmap (icon_path )
679685 else :
680- print (f"⚠️ Warning: Icon file not found at { os .path .abspath (icon_path )} " )
686+ # Fallback: try in current directory
687+ if os .path .exists ("icon.ico" ):
688+ root .iconbitmap ("icon.ico" )
689+ root .wm_iconbitmap ("icon.ico" )
690+ else :
691+ print (f"⚠️ Warning: Icon file not found at { icon_path } or current directory" )
681692 else :
682- icon_path = "icon.png"
693+ icon_path = get_resource_path ( "icon.png" )
683694 if os .path .exists (icon_path ):
684695 icon_image = tk .PhotoImage (file = icon_path )
685696 root .iconphoto (False , icon_image )
686697 else :
687- print (f"⚠️ Warning: Icon file not found at { os .path .abspath (icon_path )} " )
698+ # Fallback: try in current directory
699+ if os .path .exists ("icon.png" ):
700+ icon_image = tk .PhotoImage (file = "icon.png" )
701+ root .iconphoto (False , icon_image )
702+ else :
703+ print (f"⚠️ Warning: Icon file not found at { icon_path } or current directory" )
688704 except Exception as e :
689705 print (f"⚠️ Warning: Could not load application icon: { e } " )
690706 # Continue without icon - not a critical error
0 commit comments