1+ import os
2+ import sys
13import json
24import threading
35import time
1012logger = logging .getLogger (__name__ )
1113logging .basicConfig (level = logging .INFO , format = '%(asctime)s %(filename)s:%(lineno)d=%(levelname)s:%(message)s' )
1214
15+ def resource_path (relative_path ):
16+ """
17+ Get absolute path to resource, needed for pyinstaller to find resources.
18+ """
19+ if hasattr (sys , '_MEIPASS' ):
20+ return os .path .join (sys ._MEIPASS , relative_path )
21+ return os .path .join (os .path .abspath ("." ), relative_path )
22+
1323class M16GUI (tk .Tk ):
1424 def __init__ (self ):
1525 super ().__init__ ()
@@ -22,7 +32,7 @@ def __init__(self):
2232
2333 def create_widgets (self ) -> None :
2434 """
25- Create the layout of the GUI app
35+ Create the layout of the GUI app.
2636 """
2737 # Create a ttk style for caption labels
2838 style = ttk .Style ()
@@ -53,7 +63,8 @@ def create_widgets(self) -> None:
5363 logo_frame .grid (row = 0 , column = 0 , padx = 5 , pady = 5 , sticky = "nw" )
5464
5565 # Load and scale the logo image
56- logo = PhotoImage (file = "media/3-2-2_inverted_logo_waterlinked.png" )
66+ image_path = resource_path ("media/3-2-2_inverted_logo_waterlinked.png" )
67+ logo = PhotoImage (file = image_path )
5768 scale_factor = 17 # Adjust as needed
5869 logo_small = logo .subsample (scale_factor , scale_factor )
5970
0 commit comments