Skip to content

Commit

Permalink
New Icons, Default Team Members, Fading Background
Browse files Browse the repository at this point in the history
  • Loading branch information
DeadlyApps committed Jan 7, 2016
1 parent 3083175 commit d7e3a0b
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 25 deletions.
72 changes: 52 additions & 20 deletions Frames/MinimalScreenBlockerFrame.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from tkinter import ttk, N, E, W



from Infrastructure.ImageUtility import ImageUtility


class MinimalScreenBlockerFrame(ttk.Frame):
def __init__(self, master, controller, time_options_manager, mobber_manager, countdown_manager, settings_manager,
tips_manager,theme_manager,
tips_manager, theme_manager,
**kwargs):
super().__init__(master, **kwargs)

Expand All @@ -13,62 +17,90 @@ def __init__(self, master, controller, time_options_manager, mobber_manager, cou
self.time_options_manager = time_options_manager
self.mobber_manager = mobber_manager
self.settings_manager = settings_manager
self.build_window_content()
self.theme_manager = theme_manager
self.tips_manager = tips_manager
self.build_window_content()
self.mobber_manager.subscribe_to_mobber_list_change(self.mobber_list_change_callback)

def build_window_content(self):
center_frame = ttk.Frame(self)
center_frame.grid(row=0, column=0)
center_frame.grid_columnconfigure(0, weight=0)
center_frame.grid_columnconfigure(1, weight=0)
center_frame.grid_columnconfigure(2, weight=1)
center_frame.grid_columnconfigure(3, weight=0)
center_frame.grid_columnconfigure(4, weight=0)
center_frame.grid()
# center_frame.grid_columnconfigure(0, weight=0)
# center_frame.grid_columnconfigure(1, weight=0)
# center_frame.grid_columnconfigure(2, weight=0)
# center_frame.grid_columnconfigure(3, weight=0)
# center_frame.grid_columnconfigure(4, weight=1)
# center_frame.grid_columnconfigure(5, weight=1)
# center_frame.grid_columnconfigure(6, weight=0)
# center_frame.grid_columnconfigure(7, weight=0)
# center_frame.grid_columnconfigure(8, weight=0)
# center_frame.grid_columnconfigure(9, weight=0)

row_index = 0


image_utility = ImageUtility(self.theme_manager)

self.invisible_icon = image_utility.load('images\\invisible.png')
self.fade_label = ttk.Label(center_frame, image=self.invisible_icon)
self.fade_label.grid(row=0, column=0, sticky=(N,W))
self.fade_label.bind("<Enter>", lambda event: self.controller.fade_app())
self.fade_label.bind("<Leave>", lambda event: self.controller.unfade_app())

# 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

title = ttk.Label(center_frame, text="Mobbing Timer", font="Helvetica 60 bold italic")
title.grid(row=row_index, columnspan=5, padx=150, pady=10)
title.grid(row=row_index, column = 0, columnspan=6 ,padx=150, pady=10)
row_index += 1

self.keyboard_icon = image_utility.load('images\\keyboard.png',75,75)
self.keyboard_label = ttk.Label(center_frame, image=self.keyboard_icon)
self.keyboard_label.grid(row=row_index, column=1, sticky=(N,E))

self.current_mobber_label = ttk.Label(center_frame, text="", font="Helvetica 50 bold italic",
style="Highlight.TLabel")
self.current_mobber_label.grid(row=row_index, columnspan=5, padx=30, pady=10)
row_index += 1
self.current_mobber_label.grid(row=row_index, column=2, columnspan=1, sticky=(N,W))

self.next_mobber_label = ttk.Label(center_frame, text="", font="Helvetica 20 bold italic")
self.next_mobber_label.grid(row=row_index, columnspan=5, padx=30, pady=10)
row_index += 1


self.minions_icon = image_utility.load('images\\minions.png',75,75)
self.minions_label = ttk.Label(center_frame, image=self.minions_icon)
self.minions_label.grid(row=row_index, column=3, sticky=(N,E))

self.next_mobber_label = ttk.Label(center_frame, text="", font="Helvetica 50")
self.next_mobber_label.grid(row=row_index, column=4, columnspan=1,sticky=(N,W))
row_index += 1
# 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
start_button = ttk.Button(center_frame, text="Continue Mobbing!", style="StartButton.TButton", )
start_button.grid(row=row_index, column=1, columnspan=3, sticky=N + E + W, padx=10, pady=10)
start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=10, pady=10)
start_button.bind("<Button-1>", lambda event: self.controller.show_transparent_countdown_frame())
row_index += 1

if self.settings_manager.get_general_enable_tips():
self.tip_text = ttk.Label(center_frame, text="", font="Helvetica 15 bold", wraplength=500)
self.tip_text.grid(row=row_index, columnspan=3, padx=30, pady=10)
self.tip_text.grid(row=row_index, column=1, columnspan=4, padx=30, pady=10, sticky=(N))
row_index += 1

start_button = ttk.Button(center_frame, text="Mob Setup & Time")
start_button.grid(row=row_index, column=2, columnspan=3, sticky=N + E + W, padx=90, pady=10)
start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=90, pady=10)
start_button.bind("<Button-1>", lambda event: self.controller.show_screen_blocker_frame())
row_index += 1

start_button = ttk.Button(center_frame, text="Quit Mobbing")
start_button.grid(row=row_index, column=2, columnspan=3, sticky=N + E + W, padx=200, pady=10)
start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=90, pady=10)
start_button.bind("<Button-1>", lambda event: self.controller.quit_and_destroy_session())
row_index += 1

# 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

def mobber_list_change_callback(self, mobber_list, driver_index, navigator_index):
self.current_mobber_label['text'] = ""
self.next_mobber_label['text'] = ""
for index in range(0, mobber_list.__len__()):
name = mobber_list[index]
if index == driver_index:
self.current_mobber_label['text'] = "{}, time to drive!".format(name)
self.current_mobber_label['text'] = "{}".format(name)
if index == navigator_index:
self.next_mobber_label['text'] = "{}, up next!".format(name)
self.next_mobber_label['text'] = "{}".format(name)
if self.settings_manager.get_general_enable_tips():
self.tip_text['text'] = self.tips_manager.get_random_tip()
9 changes: 9 additions & 0 deletions Frames/MobTimerController.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, *args, **kwargs):
self.bind_all("<Control-Return>", self.launch_transparent_countdown_if_blocking)
self.time_options_manager.set_countdown_time(self.settings_manager.get_general_minutes(), self.settings_manager.get_general_seconds())


def launch_transparent_countdown_if_blocking(self, event):
if self.frame_is_screen_blocking():

Expand Down Expand Up @@ -181,6 +182,14 @@ def set_partial_screen_transparent(self):
controller.attributes("-alpha", alpha)
self.toggle_transparent_frame_position()

def fade_app(self):
for controller in self.containers:
controller.attributes("-alpha", self.settings_manager.get_continue_screen_blocker_window_alpha_percent())

def unfade_app(self):
for controller in self.containers:
controller.attributes("-alpha", 1)

def toggle_transparent_frame_position(self, e=None):
if self.state() == "withdrawn":
return
Expand Down
13 changes: 12 additions & 1 deletion Frames/ScreenBlockerFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def build_window_content(self):
self.names_list = ttk.Treeview(center_frame)
self.names_list.tag_configure(TAGNAME_CURRENT_MOBBER, background=self.theme_manager.highlight_color, foreground=self.theme_manager.background_color)
self.names_list['show'] = 'tree'
self.names_list.grid(row=row_index, rowspan=6, columnspan=2, column=1, padx=10, pady=button_pad,
self.names_list.grid(row=row_index, rowspan=7, columnspan=2, column=1, padx=10, pady=button_pad,
sticky=N + E + W + S)

remove_mobber_button = ttk.Button(center_frame, text="Remove Mobber")
Expand Down Expand Up @@ -142,6 +142,11 @@ def build_window_content(self):
clear_mobbers_button.bind("<Button-1>", lambda event: self.mobber_manager.rewind_driver())
row_index += 1

clear_mobbers_button = ttk.Button(center_frame, text="Add Team")
clear_mobbers_button.grid(row=row_index, column=3, sticky=N + E + W, padx=10, pady=button_pad)
clear_mobbers_button.bind("<Button-1>", self.add_default_team)
row_index += 1

start_button = ttk.Button(center_frame, text="Start Mobbing!", style="StartButton.TButton", )
start_button.grid(row=row_index, column=1, columnspan=3, sticky=N + E + W, padx=10, pady=button_pad)
start_button.bind("<Button-1>", lambda event: self.controller.show_transparent_countdown_frame())
Expand All @@ -156,6 +161,12 @@ def build_window_content(self):

self.focus_mobber_entry()

def add_default_team(self,event):
team = self.settings_manager.get_general_team().split(',')
self.mobber_manager.clear()
for member in team:
self.mobber_manager.add_mobber(member)

def focus_mobber_entry(self):
self.add_mobber_entry.focus_set()

Expand Down
3 changes: 0 additions & 3 deletions Frames/TransparentCountdownFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,17 @@ def create_frame_content(self):
count_down_timer_font = "Helvetica {} bold".format(
self.settings_manager.get_transparent_window_count_down_timer_font_size())
self.label_time = ttk.Label(self, text="10:00", font=count_down_timer_font)
# self.label_time.grid(row=row_index, sticky=(N))
self.label_time.pack()

row_index += 1
next_driver_font = "Helvetica {} bold".format(
self.settings_manager.get_transparent_window_next_driver_font_size())
self.label_navigator = ttk.Label(self, text=self.get_navigator_text(""), font=next_driver_font)
# self.label_navigator.grid(row=row_index, sticky=(N))
self.label_navigator.pack()

row_index += 1
driver_font = "Helvetica {} bold".format(self.settings_manager.get_transparent_window_driver_font_size())
self.label_driver = ttk.Label(self, text=self.get_driver_text(""), font=driver_font)
# self.label_driver.grid(row=row_index, sticky=(N))
self.label_driver.pack()
row_index += 1

Expand Down
Binary file added Images/invisible.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/keyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/minions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/mouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions Infrastructure/ImageUtility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from PIL import Image
from PIL import ImageTk

class ImageUtility(object):
def __init__(self, theme_manager):
self.theme_manager = theme_manager

@staticmethod
def hex_to_rgb(value):
value = value.lstrip('#')
lv = len(value)
return tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3))

def load(self, image_path, width=50, height=50):
background_color = ImageUtility.hex_to_rgb(self.theme_manager.background_color)
highlight_color = ImageUtility.hex_to_rgb(self.theme_manager.highlight_color)
original = Image.open(image_path)
resized = original.resize((width, height), Image.ANTIALIAS)
pixel_access = resized.load()

for y in range(resized.size[1]):
for x in range(resized.size[0]):
pixel = pixel_access[x, y]
if pixel[0] < 50:
pixel_access[x, y] = (background_color[0] + pixel_access[x, y][0],
background_color[1] + pixel_access[x, y][1],
background_color[2] + pixel_access[x, y][2])
elif pixel[0] > 50:
pixel_access[x, y] = (int(highlight_color[0] * pixel_access[x, y][0]/255),
int(highlight_color[1] * pixel_access[x, y][1]/255),
int(highlight_color[2] * pixel_access[x, y][2]/255))

return ImageTk.PhotoImage(resized)
Empty file.
8 changes: 8 additions & 0 deletions Infrastructure/SettingsManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ class SettingsManager(object):
TRANSPARENT_WINDOW_SETTINGS = "TRANSPARENT WINDOW SETTINGS"
GENERAL_SETTINGS = "GENERAL SETTINGS"
TIMER_SETTINGS = "TIMER SETTINGS"
CONTINUE_SCREEN_BLOCKER_SETTINGS = "CONTINUE SCREEN BLOCKER SETTINGS"

def __init__(self):
self.config = configparser.ConfigParser()
self.config.read("MobTimer.cfg")
self.window_settings_ = self.config[SettingsManager.TRANSPARENT_WINDOW_SETTINGS]
self.continue_screen_blocker_settings = self.config[SettingsManager.CONTINUE_SCREEN_BLOCKER_SETTINGS]
self.general_settings_ = self.config[SettingsManager.GENERAL_SETTINGS]
self.timer_settings_ = self.config[SettingsManager.TIMER_SETTINGS]

Expand All @@ -19,6 +21,9 @@ def get_transparent_window_screen_size_percent(self):
def get_transparent_window_alpha_percent(self):
return self.window_settings_.getfloat("alpha percentage", 0.3)

def get_continue_screen_blocker_window_alpha_percent(self):
return self.continue_screen_blocker_settings.getfloat("alpha percentage", 0.2)

def get_transparent_window_count_down_timer_font_size(self):
return self.window_settings_.getint("count down timer font size", 30)

Expand All @@ -31,6 +36,9 @@ def get_transparent_window_next_driver_font_size(self):
def get_general_theme(self):
return self.general_settings_.get("theme", 'none')

def get_general_team(self):
return self.general_settings_.get("team", 'Chris,Tom')

def get_general_minutes(self):
return self.timer_settings_.getint("minutes", 10)

Expand Down
6 changes: 5 additions & 1 deletion MobTimer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ count down timer font size = 30
driver font size = 15
next driver font size = 15

[CONTINUE SCREEN BLOCKER SETTINGS]
alpha percentage = 0.2

#Theme options either 'none' or a file form the Themes folder. e.g. 'Dark'
[GENERAL SETTINGS]
theme = Sky
theme = Dark
enable tips = True
team = Modify,MobTimer.cfg,To,Add,Members

[TIMER SETTINGS]
minutes = 5
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def get_file_paths(folder_name):

theme_file_paths = get_file_paths("Themes")
tips_file_paths = get_file_paths("Tips")
image_file_paths = get_file_paths("Images")

tcl__path = '{}\\tcl\\tcl8.6\\init.tcl'.format(os.path.dirname(sys.executable))

Expand All @@ -27,5 +28,6 @@ def get_file_paths(folder_name):
('', ["time-bomb.ico"]),
('Themes', theme_file_paths),
('Tips', tips_file_paths),
('Images', image_file_paths),
tcl__path]
, requires=['screeninfo'])

0 comments on commit d7e3a0b

Please sign in to comment.