def toggle_transparent_frame_position(self, e=None):
        if self.state() == "withdrawn":
            return

        monitors = ScreenUtility.get_monitors_or_default(self)
        monitor = monitors[self.transparent_frame_monitor_index]

        screenwidth = monitor.width
        screenheight = monitor.height

        self.set_always_on_top()
        self.remove_title_bar()
        self.disable_resizing()

        size_percentage = self.settings_manager.get_transparent_window_screen_size_percent()

        window_width = int(screenwidth * size_percentage)
        window_height = int(screenheight * size_percentage)
        if self.transparent_frame_position_index == 0:
            self.transparent_frame_position = monitor.x + screenwidth - window_width
            self.transparent_frame_monitor_index = (self.transparent_frame_monitor_index + 1) % (monitors.__len__())
        else:
            self.transparent_frame_position = monitor.x + 0
        self.transparent_frame_position_index = (self.transparent_frame_position_index + 1) % 2

        bottom_left_screen = "{}x{}+{}+{}".format(window_width, window_height, self.transparent_frame_position, monitor.y +
                                                  screenheight - window_height)
        self.geometry(bottom_left_screen)
 def toggle_transparent_frame_position_enabled(self):
     monitors = ScreenUtility.get_monitors_or_default(self)
     monitor = monitors[self.transparent_frame_monitor_index]
     screenwidth = monitor.width
     screenheight = monitor.height
     self.set_always_on_top()
     self.remove_title_bar()
     self.disable_resizing()
     size_percentage = self.settings_manager.get_transparent_window_screen_size_percent(
     )
     window_width = int(screenwidth * size_percentage)
     window_height = int(screenheight * size_percentage)
     if self.transparent_frame_position_index == 0:
         self.transparent_frame_position = monitor.x + screenwidth - window_width
         self.transparent_frame_monitor_index = (
             self.transparent_frame_monitor_index +
             1) % (monitors.__len__())
     else:
         self.transparent_frame_position = monitor.x + 0
     self.transparent_frame_position_index = (
         self.transparent_frame_position_index + 1) % 2
     bottom_left_screen = "{}x{}+{}+{}".format(
         window_width, window_height, self.transparent_frame_position,
         monitor.y + screenheight - window_height)
     self.geometry(bottom_left_screen)
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.transparent_frame_monitor_index = 0
        self.transparent_frame_position_index = 0
        self.settings_manager = SettingsManager()
        self.tips_manager = TipsManager()
        self.time_options_manager = TimeSettingsManager()
        self.mobber_manager = MobberManager(self.settings_manager.get_randomize_randomize_next_driver())
        self.countdown_manager = CountdownManager(self)
        self.session_manager = SessionManager(uuid)
        self.timer_extension_count = self.settings_manager.get_timer_extension_count()
        self.extensions_used = 0
        atexit.register(self.session_manager.clear_sessions)
        if self.session_manager.get_active_sessions().__len__() > 0:
            self.quit_and_destroy_session()

        self.session_manager.create_session()
        self.iconbitmap(default='time-bomb.ico')
        self.countdown_manager.subscribe_to_time_changes(self.show_screen_blocker_when_session_interupted)

        self.theme_manager = ThemeManager()
        theme = self.settings_manager.get_general_theme()
        if not theme == 'none':
            self.theme_manager.set_theme(theme)
        monitors = ScreenUtility.get_monitors_or_default()
        num_monitors = monitors.__len__()
        self.parent_containers = [self]
        self.containers = []
        for monitor_index in range(1, num_monitors):
            monitor_screen_blocker = Toplevel(self)
            self.parent_containers.append(monitor_screen_blocker)
        self.frame_types = (ScreenBlockerFrame, TransparentCountdownFrame, MinimalScreenBlockerFrame)
        self.frames = {}
        for frame_type in self.frame_types:
            self.frames[frame_type] = []
        for parent_container, monitor in zip(self.parent_containers, monitors):
            parent_container.grid_rowconfigure(0, weight=1)
            parent_container.grid_columnconfigure(0, weight=1)

            container = OuterFrame(parent=parent_container, monitor=monitor)
            self.containers.append(container)
            container.grid(row=0, column=0, sticky=(N, S, E, W))
            container.grid_rowconfigure(0, weight=1)
            container.grid_columnconfigure(0, weight=1)
            for frame_type in self.frame_types:
                frame_instance = frame_type(container, self, self.time_options_manager, self.mobber_manager,
                                            self.countdown_manager, self.settings_manager, self.tips_manager, self.theme_manager)
                self.frames[frame_type].append(frame_instance)
                frame_instance.grid(row=0, column=0, sticky=(N, S, E, W))
                frame_instance.grid_rowconfigure(0, weight=1)
                frame_instance.grid_columnconfigure(0, weight=1)
        self.last_frame = None
        self.show_screen_blocker_frame()
        for frame_instance in self.frames[TransparentCountdownFrame]:
            frame_instance.bind("<Enter>", self.toggle_transparent_frame_position)
        self.transparent_frame_position = 0
        self.title("Mob Timer")
        self.bind_all("<Control-Return>", self.launch_transparent_countdown_if_blocking)
        self.time_options_manager.set_countdown_time(self.settings_manager.get_timer_minutes(), self.settings_manager.get_timer_seconds())
    def build_window_content(self):

        scale = self.master.monitor.height / ScreenUtility.get_expected_height()
        unique_theme = self.theme_manager.get_unique_theme_for_scale(scale)


        center_frame = ttk.Frame(self)
        center_frame.grid()

        row_index = 0

        image_utility = ImageUtility(self.theme_manager)
        icon_size = int(75*scale)
        invisible_path = PathUtility.normalize_path('images\\invisible.png')
        self.invisible_icon = image_utility.load(invisible_path, icon_size, icon_size)
        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())

        if self.settings_manager.get_general_use_logo_image():
            self.image_utility = ImageUtility(self.theme_manager)
            image_width =int(800*scale)
            image_height = int(200*scale)
            self.background_image = self.image_utility.load(self.settings_manager.get_general_logo_image_name(), image_width,
                                                            image_height, self.settings_manager.get_general_auto_theme_logo())
            title = ttk.Label(center_frame, image=self.background_image)
        else:
            title = ttk.Label(center_frame, text="Mobbing Timer", style=unique_theme.title_style_id)
        title_padx = int(150*scale)
        pad_y = int(10*scale)
        title.grid(row=row_index, column=0, columnspan=6, padx=title_padx, pady=pad_y)
        row_index += 1


        self.keyboard_icon = image_utility.load(PathUtility.normalize_path('images\\keyboard.png'), icon_size, icon_size)
        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="", style=unique_theme.current_mobber_label_style_id)
        self.current_mobber_label.grid(row=row_index, column=2, columnspan=1, sticky=(N, W))
        self.current_mobber_label.bind("<Button-1>", lambda event: self.mobber_manager.switch_next_driver())

        self.minions_icon = image_utility.load(PathUtility.normalize_path('images\\minions.png'), icon_size, icon_size)
        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="", style=unique_theme.next_mobber_label_style_id)
        self.next_mobber_label.grid(row=row_index, column=4, columnspan=1, sticky=(N, W))
        row_index += 1

        start_button = ttk.Button(center_frame, text="Continue Mobbing!", style=unique_theme.start_button_style_id)
        start_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=pad_y, pady=pad_y)
        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="", style=unique_theme.label_style_id, wraplength=500)
            self.tip_text.grid(row=row_index, column=1, columnspan=4, padx=int(30*scale), pady=pad_y, sticky=(N))
            row_index += 1

        if self.settings_manager.get_continue_screen_blocker_show_current_time():
            self.current_time_label = ttk.Label(center_frame, text="current time", style=unique_theme.label_style_id)
            self.current_time_label.grid(row=row_index, column=1, columnspan=4, padx=int(30*scale), pady=pad_y, sticky=(N))
            row_index += 1

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

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

        quit_button = ttk.Button(center_frame, text="Quit Mobbing",style=unique_theme.button_style_id)
        quit_button.grid(row=row_index, column=1, columnspan=4, sticky=N + E + W, padx=int(90*scale), pady=pad_y)
        quit_button.bind("<Button-1>", lambda event: self.controller.quit_and_destroy_session())
        row_index += 1
示例#5
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.toggle_transparent_frame_position_function = self.toggle_transparent_frame_position_enabled
        self.transparent_frame_monitor_index = 0
        self.transparent_frame_position_index = 0
        self.settings_manager = SettingsManager()
        self.tips_manager = TipsManager()
        self.time_options_manager = TimeSettingsManager()
        self.date_time_utility = DateTimeUtility()
        self.file_utilities = FileUtilities()
        self.event_logging_manager = EventLoggingManager(self.file_utilities, self.date_time_utility)
        self.mobber_manager = MobberManager(self.settings_manager.get_randomize_randomize_next_driver())
        self.countdown_manager = CountdownManager(self)
        self.session_manager = SessionManager(uuid)
        self.timer_extension_count = self.settings_manager.get_timer_extension_count()
        self.extensions_used = 0
        atexit.register(self.session_manager.clear_sessions)
        if self.session_manager.get_active_sessions().__len__() > 0:
            self.quit_and_destroy_session()

        self.session_manager.create_session()
        if sys.platform != 'darwin':
            self.iconbitmap(default='time-bomb.ico')

        self.countdown_manager.subscribe_to_time_changes(self.show_screen_blocker_when_session_interupted)

        self.theme_manager = ThemeManager()
        theme = self.settings_manager.get_general_theme()
        if not theme == 'none':
            self.theme_manager.set_theme(theme)
        monitors = ScreenUtility.get_monitors_or_default()
        num_monitors = monitors.__len__()
        self.parent_containers = [self]
        self.containers = []
        for monitor_index in range(1, num_monitors):
            monitor_screen_blocker = Toplevel(self)
            self.parent_containers.append(monitor_screen_blocker)
        self.frame_types = (ScreenBlockerFrame, TransparentCountdownFrame, MinimalScreenBlockerFrame)
        self.frames = {}
        for frame_type in self.frame_types:
            self.frames[frame_type] = []
        for parent_container, monitor in zip(self.parent_containers, monitors):
            parent_container.grid_rowconfigure(0, weight=1)
            parent_container.grid_columnconfigure(0, weight=1)

            container = OuterFrame(parent=parent_container, monitor=monitor)
            self.containers.append(container)
            container.grid(row=0, column=0, sticky=(N, S, E, W))
            container.grid_rowconfigure(0, weight=1)
            container.grid_columnconfigure(0, weight=1)
            for frame_type in self.frame_types:
                frame_instance = frame_type(container, self, self.time_options_manager, self.mobber_manager,
                                            self.countdown_manager, self.settings_manager, self.tips_manager,
                                            self.theme_manager)
                self.frames[frame_type].append(frame_instance)
                frame_instance.grid(row=0, column=0, sticky=(N, S, E, W))
                frame_instance.grid_rowconfigure(0, weight=1)
                frame_instance.grid_columnconfigure(0, weight=1)
        self.last_frame = None
        self.show_screen_blocker_frame()
        for frame_instance in self.frames[TransparentCountdownFrame]:
            frame_instance.bind("<Enter>", self.toggle_transparent_frame_position)
        self.transparent_frame_position = 0
        self.title("Mob Timer")
        self.bind_all("<Control-Return>", self.launch_transparent_countdown_if_blocking)
        self.time_options_manager.set_countdown_time(self.settings_manager.get_timer_minutes(),
                                                     self.settings_manager.get_timer_seconds())

        self.dojo_manager = DojoManager(self)

        if self.settings_manager.get_event_logging_enabled():
            self.mobber_manager.subscribe_to_mobber_add(self.add_mobber_callback)
            self.mobber_manager.subscribe_to_mobber_remove(self.remove_mobber_callback)