Skip to content

Commit b44b3fd

Browse files
committed
Added custom colour setting and added more framework
1 parent 0762dd0 commit b44b3fd

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

__pycache__/tktools.cpython-37.pyc

-15 Bytes
Binary file not shown.

main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import tktools
22
from tktools import os, tk
3+
from tkinter import colorchooser
34

45
version = '0.0.1.4'
56

6-
77
print('Starting Fedit', version)
88
print('Home dir:', os.path.expanduser('~'))
99

@@ -39,7 +39,8 @@ def set_root_title(title):
3939
theme_current = False #False=Light True=Dark
4040
theme_light = '#f5f5f5'
4141
theme_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+
6066
def 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

6573
menubar.add_button('prefs', prefs_window, 'Prefrences')
6674
update_theme(theme_light, theme_dark)

notes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
For a colour picker:
2+
# from tkinter import colorchooser
3+
# colour_tuple = colorchooser.askcolor()

tktools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def new_file(self, *args, **kwargs):
121121
self.curr_file = None
122122
self.__updatetitle__()
123123
def config(self, **kwargs):
124-
print(kwargs)
124+
#print(kwargs)
125125
self.widget_raw().config(kwargs)
126126

127127

0 commit comments

Comments
 (0)