Skip to content

Commit 37aa294

Browse files
committed
Window now scales uniquely to each monitor
1 parent fa2407f commit 37aa294

File tree

6 files changed

+153
-75
lines changed

6 files changed

+153
-75
lines changed

Frames/MinimalScreenBlockerFrame.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from Infrastructure import MobberManager
44
from Infrastructure.ImageUtility import ImageUtility
55
from Infrastructure.PathUtility import PathUtility
6+
from Infrastructure.ScreenUtility import ScreenUtility
67

78

89
class MinimalScreenBlockerFrame(ttk.Frame):
@@ -29,79 +30,88 @@ def update_current_time(self, days, minutes, seconds):
2930
self.current_time_label["text"] = datetime.now().strftime('%Y-%m-%d %I:%M %p')
3031

3132
def build_window_content(self):
33+
34+
scale = self.master.monitor.height / ScreenUtility.get_expected_height()
35+
unique_theme = self.theme_manager.get_unique_theme_for_scale(scale)
36+
37+
3238
center_frame = ttk.Frame(self)
3339
center_frame.grid()
3440

3541
row_index = 0
3642

3743
image_utility = ImageUtility(self.theme_manager)
38-
44+
icon_size = int(75*scale)
3945
invisible_path = PathUtility.normalize_path('images\\invisible.png')
40-
self.invisible_icon = image_utility.load(invisible_path)
46+
self.invisible_icon = image_utility.load(invisible_path, icon_size, icon_size)
4147
self.fade_label = ttk.Label(center_frame, image=self.invisible_icon)
4248
self.fade_label.grid(row=0, column=0, sticky=(N, W))
4349
self.fade_label.bind("<Enter>", lambda event: self.controller.fade_app())
4450
self.fade_label.bind("<Leave>", lambda event: self.controller.unfade_app())
4551

4652
if self.settings_manager.get_general_use_logo_image():
4753
self.image_utility = ImageUtility(self.theme_manager)
48-
self.background_image = self.image_utility.load(self.settings_manager.get_general_logo_image_name(), 800,
49-
200, self.settings_manager.get_general_auto_theme_logo())
54+
image_width =int(800*scale)
55+
image_height = int(200*scale)
56+
self.background_image = self.image_utility.load(self.settings_manager.get_general_logo_image_name(), image_width,
57+
image_height, self.settings_manager.get_general_auto_theme_logo())
5058
title = ttk.Label(center_frame, image=self.background_image)
5159
else:
52-
title = ttk.Label(center_frame, text="Mobbing Timer", font="Helvetica 60 bold italic")
53-
title.grid(row=row_index, column=0, columnspan=6, padx=150, pady=10)
60+
title = ttk.Label(center_frame, text="Mobbing Timer", style=unique_theme.title_style_id)
61+
title_padx = int(150*scale)
62+
pad_y = int(10*scale)
63+
title.grid(row=row_index, column=0, columnspan=6, padx=title_padx, pady=pad_y)
5464
row_index += 1
5565

56-
self.keyboard_icon = image_utility.load(PathUtility.normalize_path('images\\keyboard.png'), 75, 75)
66+
67+
self.keyboard_icon = image_utility.load(PathUtility.normalize_path('images\\keyboard.png'), icon_size, icon_size)
5768
self.keyboard_label = ttk.Label(center_frame, image=self.keyboard_icon)
5869
self.keyboard_label.grid(row=row_index, column=1, sticky=(N, E))
5970

60-
self.current_mobber_label = ttk.Label(center_frame, text="", font="Helvetica 50 bold italic",
61-
style="Highlight.TLabel")
71+
self.current_mobber_label = ttk.Label(center_frame, text="", style=unique_theme.current_mobber_label_style_id)
6272
self.current_mobber_label.grid(row=row_index, column=2, columnspan=1, sticky=(N, W))
6373
self.current_mobber_label.bind("<Button-1>", lambda event: self.mobber_manager.switch_next_driver())
6474

65-
self.minions_icon = image_utility.load(PathUtility.normalize_path('images\\minions.png'), 75, 75)
75+
self.minions_icon = image_utility.load(PathUtility.normalize_path('images\\minions.png'), icon_size, icon_size)
6676
self.minions_label = ttk.Label(center_frame, image=self.minions_icon)
6777
self.minions_label.grid(row=row_index, column=3, sticky=(N, E))
6878

69-
self.next_mobber_label = ttk.Label(center_frame, text="", font="Helvetica 50")
79+
self.next_mobber_label = ttk.Label(center_frame, text="", style=unique_theme.next_mobber_label_style_id)
7080
self.next_mobber_label.grid(row=row_index, column=4, columnspan=1, sticky=(N, W))
7181
row_index += 1
7282

73-
start_button = ttk.Button(center_frame, text="Continue Mobbing!", style="StartButton.TButton", )
74-
start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=10, pady=10)
83+
start_button = ttk.Button(center_frame, text="Continue Mobbing!", style=unique_theme.start_button_style_id)
84+
start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=pad_y, pady=pad_y)
7585
start_button.bind("<Button-1>", lambda event: self.controller.show_transparent_countdown_frame())
7686
row_index += 1
7787

7888
if self.settings_manager.get_general_enable_tips():
79-
self.tip_text = ttk.Label(center_frame, text="", font="Helvetica 15 bold", wraplength=500)
80-
self.tip_text.grid(row=row_index, column=1, columnspan=4, padx=30, pady=10, sticky=(N))
89+
self.tip_text = ttk.Label(center_frame, text="", style=unique_theme.label_style_id, wraplength=500)
90+
self.tip_text.grid(row=row_index, column=1, columnspan=4, padx=int(30*scale), pady=pad_y, sticky=(N))
8191
row_index += 1
8292

8393
if self.settings_manager.get_continue_screen_blocker_show_current_time():
84-
self.current_time_label = ttk.Label(center_frame, text="current time", font="Helvetica 15")
85-
self.current_time_label.grid(row=row_index, column=1, columnspan=4, padx=30, pady=10, sticky=(N))
94+
self.current_time_label = ttk.Label(center_frame, text="current time", style=unique_theme.label_style_id)
95+
self.current_time_label.grid(row=row_index, column=1, columnspan=4, padx=int(30*scale), pady=pad_y, sticky=(N))
8696
row_index += 1
8797

8898
if self.settings_manager.get_timer_extension_enabled() and not self.settings_manager.get_randomize_randomize_next_driver():
8999
minutes = self.settings_manager.get_timer_extension_minutes()
90100
seconds = self.settings_manager.get_timer_extension_seconds()
91-
self.extend_time_button = ttk.Button(center_frame, text=self.get_extend_time_button_text())
92-
self.extend_time_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=90, pady=10)
101+
self.extend_time_button = ttk.Button(center_frame, text=self.get_extend_time_button_text(), style=unique_theme.button_style_id)
102+
self.extend_time_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=int(90*scale), pady=pad_y)
93103
self.showing_extend_time_button = True
94104
self.extend_time_button.bind("<Button-1>",
95105
lambda event: self.controller.rewind_and_extend(minutes, seconds))
96106
row_index += 1
97107

98-
setup_button = ttk.Button(center_frame, text="Mob Setup & Time")
99-
setup_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=90, pady=10)
108+
setup_button = ttk.Button(center_frame, text="Mob Setup & Time",style=unique_theme.button_style_id)
109+
setup_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=int(90*scale), pady=pad_y)
100110
setup_button.bind("<Button-1>", lambda event: self.controller.show_screen_blocker_frame())
101111
row_index += 1
102112

103-
quit_button = ttk.Button(center_frame, text="Quit Mobbing")
104-
quit_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=90, pady=10)
113+
quit_button = ttk.Button(center_frame, text="Quit Mobbing",style=unique_theme.button_style_id)
114+
quit_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=int(90*scale), pady=pad_y)
105115
quit_button.bind("<Button-1>", lambda event: self.controller.quit_and_destroy_session())
106116
row_index += 1
107117

Frames/MobTimerController.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import os
33
import uuid
44
from tkinter import *
5-
from tkinter import ttk
65

76
from Frames.MinimalScreenBlockerFrame import MinimalScreenBlockerFrame
7+
from Frames.OuterFrame import OuterFrame
88
from Frames.ScreenBlockerFrame import ScreenBlockerFrame
99
from Frames.TransparentCountdownFrame import TransparentCountdownFrame
1010
from Infrastructure.CountdownManager import CountdownManager
@@ -18,12 +18,6 @@
1818
from Infrastructure.TipsManager import TipsManager
1919

2020

21-
class OuterFrame(ttk.Frame):
22-
def __init__(self,monitor, parent):
23-
super().__init__(parent)
24-
self.monitor = monitor
25-
26-
2721
class MobTimerController(Tk):
2822
def __init__(self, *args, **kwargs):
2923
Tk.__init__(self, *args, **kwargs)

Frames/OuterFrame.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from tkinter import ttk
2+
3+
4+
class OuterFrame(ttk.Frame):
5+
def __init__(self,monitor, parent):
6+
super().__init__(parent)
7+
self.monitor = monitor

0 commit comments

Comments
 (0)