11import tktools
22from tktools import os , tk
33
4- version = '0.0.0.3 '
4+ version = '0.0.1.4 '
55
66
77print ('Starting Fedit' , version )
1313def set_root_title (title ):
1414 root .title (title )
1515 root .update ()
16+
1617## Main text editor
1718frame_maintextedit = tk .Frame (root )
1819widget_maintextedit = tktools .TextEditor (frame_maintextedit , root_title , set_root_title )
@@ -34,6 +35,39 @@ def set_root_title(title):
3435## Main text editor
3536widget_maintextedit .pack (expand = 1 , fill = 'both' )
3637
38+ ## Theme
39+ theme_current = False #False=Light True=Dark
40+ theme_light = '#f5f5f5'
41+ theme_dark = '#000000'
42+ def update_theme (theme , text_theme ):
43+ root .config (bg = theme )
44+ widget_maintextedit .config (bg = theme , fg = text_theme )
45+ frame_menubar .config (bg = theme )
46+ for button in menubar .buttons :
47+ menubar .buttons [button ]['raw' ].config (bg = theme , fg = text_theme )
48+
49+ def switch_theme ():
50+ global theme_current
51+ theme_current = not theme_current
52+ messages = {True : 'Switching theme to Dark' , False : 'Switching theme to Light' }
53+ print (messages [theme_current ])
54+ if theme_current == True :
55+ update_theme (theme_dark , theme_light )
56+ else :
57+ update_theme (theme_light , theme_dark )
58+ root .update ()
59+
60+ def prefs_window ():
61+ win = tktools .Window ('Preferences' , root_win = root ).window_raw ()
62+ button_switch_theme = tk .Button (win , text = 'Switch Theme' , command = switch_theme )
63+ button_switch_theme .pack (fill = 'both' , expand = 1 )
64+
65+ menubar .add_button ('prefs' , prefs_window , 'Prefrences' )
66+ update_theme (theme_light , theme_dark )
67+
68+ menubar .grid_button ('prefs' , row = 0 , column = 4 )
69+
70+
3771## Packing
3872frame_menubar .pack (side = 'top' , expand = 1 , fill = 'both' )
3973frame_maintextedit .pack (expand = 1 , fill = 'both' )
0 commit comments