11import tktools
22from tktools import os , tk
3+ from tkinter import colorchooser
34
45version = '0.0.1.4'
56
6-
77print ('Starting Fedit' , version )
88print ('Home dir:' , os .path .expanduser ('~' ))
99
@@ -39,7 +39,8 @@ def set_root_title(title):
3939theme_current = False #False=Light True=Dark
4040theme_light = '#f5f5f5'
4141theme_dark = '#000000'
42- def update_theme (theme , text_theme ):
42+ def update_theme (theme , text_theme , custom = 0 ):
43+ print ('Custom:' , custom , 'BG:' , theme , 'FG:' , text_theme )
4344 root .config (bg = theme )
4445 widget_maintextedit .config (bg = theme , fg = text_theme )
4546 frame_menubar .config (bg = theme )
@@ -57,10 +58,17 @@ def switch_theme():
5758 update_theme (theme_light , theme_dark )
5859 root .update ()
5960
61+ def set_theme ():
62+ bg_col = colorchooser .askcolor (title = 'Choose background colour' )[1 ]
63+ fg_col = colorchooser .askcolor (title = 'Choose foreground colour' )[1 ]
64+ update_theme (bg_col , fg_col , custom = 1 )
65+
6066def prefs_window ():
6167 win = tktools .Window ('Preferences' , root_win = root ).window_raw ()
6268 button_switch_theme = tk .Button (win , text = 'Switch Theme' , command = switch_theme )
69+ button_set_theme = tk .Button (win , text = 'Set Theme' , command = set_theme )
6370 button_switch_theme .pack (fill = 'both' , expand = 1 )
71+ button_set_theme .pack (fill = 'both' , expand = 1 )
6472
6573menubar .add_button ('prefs' , prefs_window , 'Prefrences' )
6674update_theme (theme_light , theme_dark )
0 commit comments