Skip to content

Commit 9fa8b49

Browse files
committed
6 Themes and the ability to set theme in the config
1 parent 138ac02 commit 9fa8b49

File tree

14 files changed

+119
-20
lines changed

14 files changed

+119
-20
lines changed

Frames/MobTimerController.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
import uuid
33
from tkinter import *
44
from tkinter import ttk
5+
56
from screeninfo import *
7+
68
from Frames.ScreenBlockerFrame import ScreenBlockerFrame
79
from Frames.TransparentCountdownFrame import TransparentCountdownFrame
810
from Infrastructure.CountdownManager import CountdownManager
911
from Infrastructure.MobberManager import MobberManager
1012
from Infrastructure.SessionManager import SessionManager
1113
from Infrastructure.SettingsManager import SettingsManager
14+
from Infrastructure.ThemeManager import ThemeManager
1215
from Infrastructure.TimeOptionsManager import TimeOptionsManager
1316

1417

@@ -26,14 +29,13 @@ def __init__(self, *args, **kwargs):
2629
self.quit_and_destroy_session()
2730

2831
self.session_manager.create_session()
29-
32+
self.iconbitmap(default='time-bomb.ico')
3033
self.countdown_manager.subscribe_to_time_changes(self.show_screen_blocker_when_session_interupted)
3134

32-
style = ttk.Style()
33-
print(style.theme_names())
35+
self.theme_manager = ThemeManager()
3436
theme = self.settings_manager.get_general_theme()
35-
if theme != "none":
36-
style.theme_use(theme)
37+
if not theme == 'none':
38+
self.theme_manager.set_theme(theme)
3739

3840
monitors = get_monitors()
3941
num_monitors = monitors.__len__()

Frames/ScreenBlockerFrame.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def mobber_list_change_callback(self, mobber_list, driver_index, navigator_index
2323
for index in range(0, mobber_list.__len__()):
2424
name = mobber_list[index]
2525
if index == driver_index:
26+
self.current_dev['text'] = "{} time to drive!".format(name)
2627
name += " <= Current"
2728
if index == navigator_index:
2829
name += " <= Next"
@@ -39,7 +40,7 @@ def toggle_geometry(self, event):
3940
self._geom = geom
4041

4142
def build_window_content(self):
42-
center_frame = Frame(self)
43+
center_frame = ttk.Frame(self)
4344
center_frame.grid(row=0, column=0)
4445
center_frame.grid_columnconfigure(0, weight=1)
4546
center_frame.grid_columnconfigure(1, weight=0)
@@ -73,7 +74,11 @@ def build_window_content(self):
7374
self.label_seconds.bind("<Button-3>", lambda event: self.time_options_manager.decrement_seconds())
7475
row_index += 1
7576

76-
self.add_mobber_entry = ttk.Entry(center_frame, text="Add Mobber", font="Helvetica 16 bold")
77+
self.current_dev = ttk.Label(center_frame, text="", font="Helvetica 70 bold italic")
78+
self.current_dev.grid(row=row_index, columnspan=5)
79+
row_index += 1
80+
81+
self.add_mobber_entry = ttk.Entry(center_frame, style="EntryStyle.TEntry", text="Add Mobber", font="Helvetica 16 bold")
7782
self.add_mobber_entry.grid(row=row_index, column = 1, columnspan=2, sticky=N + E + W, padx=10, pady=10)
7883
self.add_mobber_entry.bind("<Return>", self.add_mobber_left_click)
7984
self.add_mobber_entry.bind("<Control-Return>", self.launch_transparent_countdown)
@@ -84,7 +89,8 @@ def build_window_content(self):
8489
row_index += 1
8590

8691
self.names_list = ttk.Treeview(center_frame)
87-
self.names_list.grid(row=row_index, rowspan=6, columnspan=2, column=1, padx=10, pady=10, sticky=N + E + W)
92+
self.names_list['show'] = 'tree'
93+
self.names_list.grid(row=row_index, rowspan=6, columnspan=2, column=1, padx=10, pady=10, sticky=N + E + W + S)
8894

8995
remove_mobber_button = ttk.Button(center_frame, text="Remove Mobber")
9096
remove_mobber_button.grid(row=row_index, column=3, sticky=N + E + W, padx=10, pady=10)
@@ -117,7 +123,7 @@ def build_window_content(self):
117123
clear_mobbers_button.bind("<Button-1>", lambda event: self.mobber_manager.rewind_driver())
118124
row_index += 1
119125

120-
start_button = ttk.Button(center_frame, text="Start Mobbing!")
126+
start_button = ttk.Button(center_frame, text="Start Mobbing!", style="StartButton.TButton",)
121127
start_button.grid(row=row_index, column=1,columnspan=3, sticky=N + E + W, padx=10, pady=10)
122128
start_button.bind("<Button-1>", self.launch_transparent_countdown)
123129
row_index += 1

Infrastructure/SettingsManager.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ class SettingsManager(object):
88
def __init__(self):
99
self.config = configparser.ConfigParser()
1010
self.config.read("MobTimer.cfg")
11-
print(self.config.__len__())
1211
# with open("MobTimer.cfg", 'w') as configfile:
1312
# self.config.write(configfile)
1413

@@ -28,4 +27,4 @@ def get_transparent_window_next_driver_font_size(self):
2827
return self.config[SettingsManager.TRANSPARENT_WINDOW_SETTINGS].getint("next driver font size", 10)
2928

3029
def get_general_theme(self):
31-
return self.config[SettingsManager.GENERAL_SETTINGS].get("theme", 'clam')
30+
return self.config[SettingsManager.GENERAL_SETTINGS].get("theme", 'none')

Infrastructure/ThemeManager.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import configparser
2+
from tkinter import ttk
3+
4+
5+
class ThemeManager(object):
6+
THEME_SETTINGS = 'THEME SETTINGS'
7+
8+
def set_theme(self, theme_name):
9+
cfg_file = "Themes/{}.cfg".format(theme_name)
10+
config = configparser.ConfigParser()
11+
config.read(cfg_file)
12+
theme_settings_ = config[ThemeManager.THEME_SETTINGS]
13+
background_color = theme_settings_.get('background_color')
14+
button_color = theme_settings_.get('button_color')
15+
text_color = theme_settings_.get('text_color')
16+
highlight_color = theme_settings_.get('highlight_color')
17+
18+
style = ttk.Style()
19+
style.theme_use('default')
20+
21+
style.configure('TFrame', background=background_color)
22+
style.configure('TButton',
23+
background=button_color,
24+
foreground=text_color)
25+
style.map('TButton',
26+
foreground=[('disabled', text_color),
27+
('pressed', text_color),
28+
('active', background_color)],
29+
background=[('disabled', button_color),
30+
('pressed', '!focus', button_color),
31+
('active', highlight_color)])
32+
33+
style.configure('TLabel', background=background_color, foreground=text_color)
34+
style.configure("Treeview", background=background_color,
35+
foreground=text_color, fieldbackground=background_color, font="Helvetica 16 bold")
36+
style.element_create("plain.field", "from", "clam")
37+
style.configure("StartButton.TButton",font="Helvetica 50 bold")
38+
39+
style.configure("EntryStyle.TEntry",
40+
foreground=background_color,
41+
fieldbackground=highlight_color)

MobTimer.cfg

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#These settings effect the transparent count down page.
22
[TRANSPARENT WINDOW SETTINGS]
3-
size percentage = 0.3
4-
alpha percentage = 0.2
5-
count down timer font size = 140
6-
driver font size = 40
7-
next driver font size = 40
3+
size percentage = 0.1
4+
alpha percentage = 0.5
5+
count down timer font size = 40
6+
driver font size = 10
7+
next driver font size = 20
88

9-
#Theme options are 'winnative', 'clam', 'alt', 'default', 'classic', 'vista', 'xpnative', 'none'
9+
#Theme options either 'none' or a file form the Themes folder. e.g. 'Dark'
1010
[GENERAL SETTINGS]
11-
theme = winnative
11+
theme = Dark

MobTimer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
from Frames.MobTimerController import MobTimerController
22
root = MobTimerController()
3-
43
root.mainloop()

Themes/Candy.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Change the following settings to modify the color scheme
2+
[THEME SETTINGS]
3+
background_color = #5B0B11
4+
button_color = #AA6939
5+
text_color = #C3F6BB
6+
highlight_color = #549992

Themes/Dark.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Change the following settings to modify the color scheme
2+
[THEME SETTINGS]
3+
background_color = #1D1C1A
4+
button_color = #474540
5+
text_color = #C9C5BA
6+
highlight_color = #FFAE00

Themes/Foo.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Change the following settings to modify the color scheme
2+
[THEME SETTINGS]
3+
background_color = #08313A
4+
button_color = #2A7F41
5+
text_color = #F69487
6+
highlight_color = #B7F2C7

Themes/Forest.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Change the following settings to modify the color scheme
2+
[THEME SETTINGS]
3+
background_color = #006100
4+
button_color = #004949
5+
text_color = #7B9F35
6+
highlight_color = #2D882D

0 commit comments

Comments
 (0)