@@ -10,30 +10,38 @@ class MobTimerController(Tk):
1010 def __init__ (self , * args , ** kwargs ):
1111 Tk .__init__ (self , * args , ** kwargs )
1212
13- container = Frame (self )
14- container .pack (side = "top" , fill = "both" , expand = True )
15- container .grid_rowconfigure (0 , weight = 1 )
16- container .grid_columnconfigure (0 , weight = 1 )
13+
1714
1815 self .time_options_manager = TimeOptionsManager ()
1916 self .mobber_manager = MobberManager ()
20- self .countdown_manager = CountdownManager (container )
17+ self .countdown_manager = CountdownManager (self )
2118
19+ self .containers = [self , Toplevel (self )]
20+ self .frame_types = (ScreenBlockerFrame , TransparentCountdownFrame )
2221 self .frames = {}
23- for F in (ScreenBlockerFrame , TransparentCountdownFrame ):
24- frame = F (container , self , self .time_options_manager , self .mobber_manager , self .countdown_manager )
25- self .frames [F ] = frame
26- frame .grid (row = 0 , column = 0 , sticky = "nsew" )
22+ for frame_type in self .frame_types :
23+ self .frames [frame_type ] = []
24+ for s in self .containers :
25+ container = Frame (s )
26+ container .grid (row = 0 , column = 0 , sticky = N + S + E + W )
27+ container .grid_rowconfigure (0 , weight = 1 )
28+ container .grid_columnconfigure (0 , weight = 1 )
29+ for frame_type in self .frame_types :
30+ frame_instance = frame_type (container , self , self .time_options_manager , self .mobber_manager , self .countdown_manager )
31+ self .frames [frame_type ].append (frame_instance )
32+ frame_instance .grid (row = 0 , column = 0 , sticky = "nsew" )
2733 self .last_frame = None
2834 self .show_screen_blocker_frame ()
29- self .frames [TransparentCountdownFrame ].bind ("<Enter>" , self .toggle_transparent_frame_position )
35+ for frame_instance in self .frames [TransparentCountdownFrame ]:
36+ frame_instance .bind ("<Enter>" , self .toggle_transparent_frame_position )
3037 self .transparent_frame_position = 0
3138
3239 def show_frame (self , frame_class ):
3340 switched_frames = False
3441 if self .last_frame != frame_class :
35- frame = self .frames [frame_class ]
36- frame .tkraise ()
42+ for frame_instances in self .frames [frame_class ]:
43+ # for frame in frame_instances:
44+ frame_instances .tkraise ()
3745 switched_frames = True
3846 self .last_frame = frame_class
3947 return switched_frames
@@ -52,49 +60,46 @@ def get_current_window_geometry(self):
5260 self .winfo_screenwidth (), self .winfo_screenheight ())
5361
5462 def disable_resizing (self ):
55- self .resizable (0 , 0 )
63+ for container in self .containers :
64+ container .resizable (0 , 0 )
5665
5766 def remove_title_bar (self ):
58- self .overrideredirect (1 )
67+ for container in self .containers :
68+ container .overrideredirect (1 )
5969
6070 def set_always_on_top (self ):
61- self .wm_attributes ("-topmost" , 1 )
71+ for container in self .containers :
72+ container .wm_attributes ("-topmost" , 1 )
6273
6374 def set_full_screen_always_on_top (self ):
64- controller = self
65- controller .geometry (self .get_current_window_geometry ())
6675 self .set_always_on_top ()
6776 self .remove_title_bar ()
6877 self .disable_resizing ()
6978 top_left_screen = "+0+0"
70- controller .geometry (top_left_screen )
71-
72- controller .wait_visibility (controller )
73- controller .attributes ("-alpha" , 1 )
79+ for container in self .containers :
80+ container .geometry (self .get_current_window_geometry ())
81+ container .geometry (top_left_screen )
82+ container .wait_visibility (container )
83+ container .attributes ("-alpha" , 1 )
7484
7585 def set_partial_screen_transparent (self ):
76- screenwidth = self .winfo_screenwidth ()
77- screenheight = self .winfo_screenheight ()
78-
79- controller = self
80-
8186 self .set_always_on_top ()
8287 self .remove_title_bar ()
8388 self .disable_resizing ()
84-
85- window_width = int (screenwidth * 0.3 )
86- window_height = int (screenheight * 0.3 )
87- window_size = "{0}x{1}+0+0" .format (window_width , window_height )
88- controller .geometry (window_size )
89- controller .attributes ("-alpha" , 0.3 )
89+ for controller in self .containers :
90+ screenwidth = self .winfo_screenwidth ()
91+ screenheight = self .winfo_screenheight ()
92+ window_width = int (screenwidth * 0.3 )
93+ window_height = int (screenheight * 0.3 )
94+ window_size = "{0}x{1}+0+0" .format (window_width , window_height )
95+ controller .geometry (window_size )
96+ controller .attributes ("-alpha" , 0.3 )
9097 self .toggle_transparent_frame_position ()
9198
9299 def toggle_transparent_frame_position (self , e = None ):
93100 screenwidth = self .winfo_screenwidth ()
94101 screenheight = self .winfo_screenheight ()
95102
96- controller = self
97-
98103 self .set_always_on_top ()
99104 self .remove_title_bar ()
100105 self .disable_resizing ()
@@ -108,4 +113,5 @@ def toggle_transparent_frame_position(self, e=None):
108113 self .transparent_frame_position = 0
109114
110115 bottom_left_screen = "+{}+{}" .format (self .transparent_frame_position , screenheight - window_height )
111- controller .geometry (bottom_left_screen )
116+ for controller in self .containers :
117+ controller .geometry (bottom_left_screen )
0 commit comments