85
85
86
86
###########################################################################################################################################
87
87
88
- CFG_KEY_DARK_THEME = 'dark_theme '
88
+ CFG_THEME = 'theme '
89
89
CFG_KEY_FULL_CRC = 'show_full_crc'
90
90
CFG_KEY_SHOW_TOOLTIPS_INFO = 'show_tooltips_info'
91
91
CFG_KEY_SHOW_TOOLTIPS_HELP = 'show_tooltips_help'
128
128
129
129
CFG_KEY_SHOW_PREVIEW = 'preview_shown'
130
130
131
- CFG_lang = 'lang'
131
+ CFG_LANG = 'lang'
132
132
133
133
cfg_defaults = {
134
- CFG_KEY_DARK_THEME : False ,
134
+ CFG_THEME : 'Vista Light' if windows else 'Clam Light' ,
135
135
CFG_KEY_FULL_CRC :False ,
136
136
CFG_KEY_SHOW_TOOLTIPS_INFO :True ,
137
137
CFG_KEY_SHOW_TOOLTIPS_HELP :True ,
163
163
CFG_KEY_MARK_RE_0 :False ,
164
164
CFG_KEY_MARK_RE_1 :False ,
165
165
CFG_KEY_SHOW_PREVIEW :False ,
166
- CFG_lang :'English'
166
+ CFG_LANG :'English'
167
167
}
168
168
169
169
NAME = {DELETE :'Delete' ,SOFTLINK :'Softlink' ,HARDLINK :'Hardlink' ,WIN_LNK :'.lnk file' }
@@ -578,7 +578,7 @@ def __init__(self,cwd,paths_to_add=None,exclude=None,exclude_regexp=None,norun=N
578
578
self .cfg_get_bool = self .cfg .get_bool
579
579
self .cfg_get = self .cfg .get
580
580
581
- langs .set ( self .cfg_get (CFG_lang ) )
581
+ langs .set ( self .cfg_get (CFG_LANG ) )
582
582
583
583
self .exclude_frames = []
584
584
@@ -615,7 +615,21 @@ def __init__(self,cwd,paths_to_add=None,exclude=None,exclude_regexp=None,norun=N
615
615
self_main .withdraw ()
616
616
617
617
####################################
618
- black_theme = self .cfg_get_bool (CFG_KEY_DARK_THEME )
618
+ self .themes_combos = {}
619
+ {'Clam Light' :('clam' ,0 ),'Clam Dark' :('clam' ,1 ),'Classic Light' :('classic' ,0 ),'Classic Dark' :('classic' ,1 ),'Vista Light' :('vista' ,0 ),'Vista Dark' :('vista' ,0 )}
620
+
621
+ themes_names = [ 'Clam' , 'Alt' , 'Default' , 'Classic' ]
622
+ if windows :
623
+ themes_names = ['Vista' ] + themes_names
624
+
625
+ for name in themes_names :
626
+ for darkness ,darknesscode in (('' ,0 ),('Dark' ,1 )):
627
+ full_name = name + ' ' + darkness
628
+ self .themes_combos [full_name ]= name .lower (),darknesscode
629
+
630
+ self .default_theme = 'vista' if windows else 'clam'
631
+
632
+ theme_name ,black_theme = self .themes_combos .get (self .cfg_get (CFG_THEME ),(self .default_theme ,0 ))
619
633
620
634
if black_theme :
621
635
bg_sel = 'gray30'
@@ -752,20 +766,19 @@ def __init__(self,cwd,paths_to_add=None,exclude=None,exclude_regexp=None,norun=N
752
766
####################################################################
753
767
style = Style ()
754
768
755
- #('aqua', 'step', 'clam', 'alt', 'default', 'classic')
756
-
757
- if env_theme := os_environ .get ('DUDE_THEME' ):
758
- print (f'{ env_theme = } ' )
759
- parent_theme = env_theme
760
- else :
761
- parent_theme = 'vista' if windows else 'clam'
769
+ parent_them = theme_name
762
770
763
771
try :
764
- style .theme_create ( "dummy" , parent = parent_theme )
772
+ style .theme_create ( "dummy" , parent = theme_name )
765
773
except Exception as e :
766
774
print (e )
767
- print ('Try one of: aqua,step,clam,alt,default,classic' )
768
- sys_exit (1 )
775
+
776
+ try :
777
+ style .theme_create ( "dummy" , parent = self .default_theme )
778
+ except Exception as e2 :
779
+ print (e2 )
780
+
781
+ sys_exit (1 )
769
782
770
783
bg_color = self .bg_color = style .lookup ('TFrame' , 'background' )
771
784
preview .configure (bg = bg_color )
@@ -776,16 +789,14 @@ def __init__(self,cwd,paths_to_add=None,exclude=None,exclude_regexp=None,norun=N
776
789
777
790
style_configure = style .configure
778
791
779
- if not env_theme :
780
- style_map ('no_focus.Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_sel ),('' ,self .bg_content )])
781
- style_map ('Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_sel ),('' ,self .bg_content )] )
782
- style_map ('semi_focus.Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_focus_off ),('' ,self .bg_content )])
783
- #works but not for every theme
784
- style_configure ("Treeview" , fieldbackground = self .bg_content )
785
-
786
- style_map ("TCheckbutton" ,indicatorbackground = [("disabled" ,self .bg_color ),('' ,'white' )],indicatorforeground = [("disabled" ,'darkgray' ),('' ,'black' )],foreground = [('disabled' ,"gray" ),('' ,"black" )])
787
- style_map ("TEntry" , foreground = [("disabled" ,'darkgray' ),('' ,'black' )],fieldbackground = [("disabled" ,self .bg_color ),('' ,'white' )])
792
+ style_map ('no_focus.Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_sel ),('' ,self .bg_content )])
793
+ style_map ('Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_sel ),('' ,self .bg_content )] )
794
+ style_map ('semi_focus.Treeview' , background = [('focus' ,bg_focus ),('selected' ,bg_focus_off ),('' ,self .bg_content )])
795
+ #works but not for every theme
796
+ style_configure ("Treeview" , fieldbackground = self .bg_content )
788
797
798
+ style_map ("TCheckbutton" ,indicatorbackground = [("disabled" ,self .bg_color ),('' ,'white' )],indicatorforeground = [("disabled" ,'darkgray' ),('' ,'black' )],foreground = [('disabled' ,"gray" ),('' ,"black" )])
799
+ style_map ("TEntry" , foreground = [("disabled" ,'darkgray' ),('' ,'black' )],fieldbackground = [("disabled" ,self .bg_color ),('' ,'white' )])
789
800
790
801
style_map ("TButton" , fg = [('disabled' ,"gray" ),('' ,"black" )] )
791
802
@@ -1764,7 +1775,7 @@ def get_settings_dialog(self):
1764
1775
1765
1776
self .settings_dialog = GenericDialog (self .main ,self .main_icon_tuple ,self .bg_color ,STR ('Settings' ),pre_show = self .pre_show_settings ,post_close = self .post_close )
1766
1777
1767
- self .dark_theme = BooleanVar ()
1778
+ self .theme = StringVar ()
1768
1779
self .show_full_crc = BooleanVar ()
1769
1780
self .show_tooltips_info = BooleanVar ()
1770
1781
self .show_tooltips_help = BooleanVar ()
@@ -1790,7 +1801,6 @@ def get_settings_dialog(self):
1790
1801
self .folders_open_wrapper_params = StringVar ()
1791
1802
1792
1803
self .settings = [
1793
- (self .dark_theme ,CFG_KEY_DARK_THEME ),
1794
1804
(self .show_full_crc ,CFG_KEY_FULL_CRC ),
1795
1805
(self .show_tooltips_info ,CFG_KEY_SHOW_TOOLTIPS_INFO ),
1796
1806
(self .show_tooltips_help ,CFG_KEY_SHOW_TOOLTIPS_HELP ),
@@ -1807,6 +1817,7 @@ def get_settings_dialog(self):
1807
1817
(self .allow_delete_non_duplicates ,CFG_ALLOW_DELETE_NON_DUPLICATES )
1808
1818
]
1809
1819
self .settings_str = [
1820
+ (self .theme ,CFG_THEME ),
1810
1821
(self .show_mode ,CFG_KEY_SHOW_MODE ),
1811
1822
(self .file_open_wrapper ,CFG_KEY_WRAPPER_FILE ),
1812
1823
(self .folders_open_wrapper ,CFG_KEY_WRAPPER_FOLDERS ),
@@ -1819,17 +1830,20 @@ def get_settings_dialog(self):
1819
1830
lang_frame .grid (row = row , column = 0 , sticky = 'news' ,padx = 4 ,pady = 4 ) ; row += 1
1820
1831
1821
1832
Label (lang_frame ,text = STR ('Language:' ),anchor = 'w' ).grid (row = 0 , column = 0 , sticky = 'wens' ,padx = 8 ,pady = 4 )
1822
-
1823
1833
self .lang_var = StringVar ()
1824
1834
self .lang_cb = Combobox (lang_frame ,values = list (langs .lang_dict .keys ()),textvariable = self .lang_var ,state = 'readonly' ,width = 16 )
1825
1835
self .lang_cb .grid (row = 0 , column = 1 , sticky = 'news' ,padx = 4 ,pady = 4 )
1826
1836
1827
- Checkbutton (lang_frame , text = STR ('Dark Theme' ), variable = self .dark_theme ,command = self .dark_mode_change ).grid (row = 0 ,column = 3 ,sticky = 'nsew' ,padx = 20 ,pady = 2 )
1837
+
1838
+ Label (lang_frame ,text = STR ('Theme:' ),anchor = 'w' ).grid (row = 0 , column = 2 , sticky = 'wens' ,padx = 8 ,pady = 4 )
1839
+ self .theme_var = StringVar ()
1840
+
1841
+ self .theme_cb = Combobox (lang_frame ,values = list (self .themes_combos .keys ()),textvariable = self .theme_var ,state = 'readonly' ,width = 16 )
1842
+ self .theme_cb .grid (row = 0 , column = 3 , sticky = 'news' ,padx = 4 ,pady = 4 )
1843
+
1828
1844
lang_frame .grid_columnconfigure ( 2 , weight = 1 )
1829
1845
lang_frame .grid_columnconfigure ( 4 , weight = 1 )
1830
1846
1831
- self .lang_cb .bind ('<<ComboboxSelected>>' , self .lang_change )
1832
-
1833
1847
label_frame = LabelFrame (self .settings_dialog .area_main , text = STR ("Results display mode" ),borderwidth = 2 ,bg = self .bg_color )
1834
1848
label_frame .grid (row = row ,column = 0 ,sticky = 'wens' ,padx = 3 ,pady = 3 ) ; row += 1
1835
1849
@@ -1913,19 +1927,12 @@ def get_settings_dialog(self):
1913
1927
1914
1928
self .settings_dialog .area_main .grid_rowconfigure (row , weight = 1 ); row += 1
1915
1929
1916
- self .lang_var .set (self .cfg_get (CFG_lang ))
1917
-
1918
1930
self .settings_dialog_created = True
1919
1931
1920
- return self .settings_dialog
1921
-
1922
- def lang_change (self ,event ):
1923
- new_val = self .lang_var .get ()
1924
- self .cfg .set (CFG_lang ,new_val )
1925
- self .get_info_dialog_on_settings ().show (STR ('Language Changed' ),STR ('Application restart required\n for changes to take effect' ,new_val ) + '\n \n ' + STR ('Translations are made using AI\n If any corrections are necessary,\n please contact the author.' ,new_val ) )
1932
+ self .lang_var .set (self .cfg_get (CFG_LANG ))
1933
+ self .theme_var .set (self .cfg_get (CFG_THEME ))
1926
1934
1927
- def dark_mode_change (self ):
1928
- self .get_info_dialog_on_settings ().show (STR ('Color Theme Changed' ),STR ('Application restart required\n for changes to take effect' ))
1935
+ return self .settings_dialog
1929
1936
1930
1937
info_dialog_on_main_created = False
1931
1938
@restore_status_line
@@ -4542,9 +4549,20 @@ def settings_ok(self):
4542
4549
update0 = False
4543
4550
update1 = False
4544
4551
update2 = False
4552
+ update3 = False
4553
+
4554
+ if self .cfg_get (CFG_LANG )!= self .lang_var .get ():
4555
+ new_val = self .lang_var .get ()
4556
+ self .cfg .set (CFG_LANG ,new_val )
4557
+ self .get_info_dialog_on_settings ().show (STR ('Language Changed' ),STR ('Application restart required\n for changes to take effect' ,new_val ) + '\n \n ' + STR ('Translations are made using AI\n If any corrections are necessary,\n please contact the author.' ,new_val ) )
4545
4558
4546
- if self .cfg_get_bool (CFG_KEY_DARK_THEME )!= self .dark_theme .get ():
4547
- self .cfg .set_bool (CFG_KEY_DARK_THEME ,self .dark_theme .get ())
4559
+ update3 = True
4560
+
4561
+ if self .cfg_get (CFG_THEME )!= self .theme_var .get ():
4562
+ self .cfg .set (CFG_THEME ,self .theme_var .get ())
4563
+
4564
+ if not update3 :
4565
+ self .get_info_dialog_on_settings ().show (STR ('Theme Changed' ),STR ('Application restart required\n for changes to take effect' ))
4548
4566
4549
4567
if self .cfg_get_bool (CFG_KEY_FULL_CRC )!= self .show_full_crc .get ():
4550
4568
self .cfg .set_bool (CFG_KEY_FULL_CRC ,self .show_full_crc .get ())
@@ -4622,6 +4640,9 @@ def settings_ok(self):
4622
4640
else :
4623
4641
self .tree_folder_update_none ()
4624
4642
4643
+ if update3 :
4644
+ CFG_THEME
4645
+
4625
4646
def settings_reset (self ):
4626
4647
_ = {var .set (cfg_defaults [key ]) for var ,key in self .settings }
4627
4648
_ = {var .set (cfg_defaults [key ]) for var ,key in self .settings_str }
0 commit comments