163163
164164MAIN_DIRECTORY = Path (__file__ ).resolve ().parent
165165THEMES_DIR = MAIN_DIRECTORY / "res/themes"
166+ VERSION_FILE = MAIN_DIRECTORY / "version.txt"
166167
167168circular_mask = Image .open (MAIN_DIRECTORY / "res/backgrounds/circular-mask.png" )
169+ DISABLED_COLOR = "#C0C0C0"
168170
169171
170172def get_theme_data (name : str ):
@@ -323,6 +325,17 @@ def __init__(self):
323325 "Fans missing from the list? Install lm-sensors package\n "
324326 "and run 'sudo sensors-detect' command, then reboot." )
325327
328+ try :
329+ version = open (VERSION_FILE ).readline ()
330+ except :
331+ try :
332+ version = subprocess .check_output (['git' , 'rev-parse' , '--short' , 'HEAD' ]).decode ('utf-8' )
333+ except :
334+ version = "0.0.0"
335+
336+ version_label = ttk .Label (self .window , text = version , foreground = DISABLED_COLOR )
337+ version_label .place (x = 5 , y = 550 )
338+
326339 self .weather_ping_btn = ttk .Button (self .window , text = "Weather & ping" ,
327340 command = lambda : self .on_weatherping_click ())
328341 self .weather_ping_btn .place (x = 80 , y = 520 , height = 50 , width = 130 )
@@ -510,13 +523,6 @@ def on_weatherping_click(self):
510523 self .more_config_window .show ()
511524
512525 def on_open_theme_folder_click (self ):
513- # path = f'"{MAIN_DIRECTORY}res/themes"'
514- # if platform.system() == "Windows":
515- # os.startfile(path)
516- # elif platform.system() == "Darwin":
517- # subprocess.Popen(["open", path])
518- # else:
519- # subprocess.Popen(["xdg-open", path])
520526 path = MAIN_DIRECTORY / "res/themes"
521527
522528 if platform .system () == "Windows" :
@@ -527,24 +533,35 @@ def on_open_theme_folder_click(self):
527533 subprocess .Popen (["xdg-open" , str (path )])
528534
529535 def on_theme_editor_click (self ):
530- theme_editor = next (MAIN_DIRECTORY .glob ("theme-editor.*" ))
531-
532- if platform .system () == "Windows" :
533- subprocess .Popen ([str (theme_editor ), self .theme_cb .get ()], shell = True )
534- else :
535- subprocess .Popen ([str (theme_editor ), self .theme_cb .get ()])
536+ try :
537+ # Load Python file with local python interpreter (useful for venvs)
538+ theme_editor = next (MAIN_DIRECTORY .glob ("theme-editor.py" ))
539+ subprocess .Popen ([sys .executable , str (theme_editor ), self .theme_cb .get ()])
540+ except :
541+ # Load binary (for releases) or Python file with system interpreter
542+ theme_editor = next (MAIN_DIRECTORY .glob ("theme-editor*" ))
543+ if platform .system () == "Windows" :
544+ subprocess .Popen ([str (theme_editor ), self .theme_cb .get ()], shell = True )
545+ else :
546+ subprocess .Popen ([str (theme_editor ), self .theme_cb .get ()])
536547
537548 def on_save_click (self ):
538549 self .save_config_values ()
539550
540551 def on_saverun_click (self ):
541552 self .save_config_values ()
542- main_file = next (MAIN_DIRECTORY .glob ("main.*" ))
543553
544- if platform .system () == "Windows" :
545- subprocess .Popen ([str (main_file )], shell = True )
546- else :
547- subprocess .Popen ([str (main_file )])
554+ try :
555+ # Load Python file with local python interpreter (useful for venvs)
556+ main_file = next (MAIN_DIRECTORY .glob ("main.py" ))
557+ subprocess .Popen ([sys .executable , str (main_file )])
558+ except :
559+ # Load binary (for releases) or Python file with system interpreter
560+ main_file = next (MAIN_DIRECTORY .glob ("main*" ))
561+ if platform .system () == "Windows" :
562+ subprocess .Popen ([str (main_file )], shell = True )
563+ else :
564+ subprocess .Popen ([str (main_file )])
548565
549566 self .window .destroy ()
550567
@@ -556,10 +573,10 @@ def on_model_change(self, e=None):
556573 self .show_hide_brightness_warning ()
557574 model = self .model_cb .get ()
558575 if model == SIMULATED_MODEL :
559- self .com_cb .configure (state = "disabled" , foreground = "#C0C0C0" )
560- self .orient_cb .configure (state = "disabled" , foreground = "#C0C0C0" )
576+ self .com_cb .configure (state = "disabled" , foreground = DISABLED_COLOR )
577+ self .orient_cb .configure (state = "disabled" , foreground = DISABLED_COLOR )
561578 self .brightness_slider .configure (state = "disabled" )
562- self .brightness_val_label .configure (foreground = "#C0C0C0" )
579+ self .brightness_val_label .configure (foreground = DISABLED_COLOR )
563580 else :
564581 self .com_cb .configure (state = "readonly" , foreground = "#000" )
565582 self .orient_cb .configure (state = "readonly" , foreground = "#000" )
@@ -591,8 +608,8 @@ def on_size_change(self, e=None):
591608 def on_hwlib_change (self , e = None ):
592609 hwlib = [k for k , v in hw_lib_map .items () if v == self .hwlib_cb .get ()][0 ]
593610 if hwlib == "STUB" or hwlib == "STATIC" :
594- self .eth_cb .configure (state = "disabled" , foreground = "#C0C0C0" )
595- self .wl_cb .configure (state = "disabled" , foreground = "#C0C0C0" )
611+ self .eth_cb .configure (state = "disabled" , foreground = DISABLED_COLOR )
612+ self .wl_cb .configure (state = "disabled" , foreground = DISABLED_COLOR )
596613 else :
597614 self .eth_cb .configure (state = "readonly" , foreground = "#000" )
598615 self .wl_cb .configure (state = "readonly" , foreground = "#000" )
0 commit comments