Improved enums and error handling

This commit is contained in:
2023-01-26 13:29:30 +01:00
parent bfcdcce11d
commit 062a38ceec
6 changed files with 82 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ from classes.custom.image_label import ImageLabel
from classes.custom.themed_frame import ThemedFrame
from classes.custom.themed_toplevel import ThemedToplevel
from classes.enums import Theme
from modules.logger import logger
from modules.theme_titlebar import theme_title_bar
from modules.utils import configGet, configSet, resize_window, set_icon, use_dark_mode
@@ -31,7 +32,7 @@ class ToplevelWelcome(ThemedToplevel):
sv_ttk.init_theme(self)
if use_dark_mode():
theme_title_bar(self, mode="dark")
theme_title_bar(self, mode=Theme.DARK)
self.update()
set_icon(self)
@@ -287,20 +288,23 @@ class ToplevelWelcome(ThemedToplevel):
def change_theme(self, *args):
if self.stage_option_menu_var.get().strip().lower() == "auto":
self.stage_option_menu_var_real = "dark" if use_dark_mode(no_config=True) is True else "light"
if self.stage_option_menu_var.get().strip().lower() == Theme.AUTO.value:
self.stage_option_menu_var_real = Theme.DARK if use_dark_mode(no_config=True) is True else Theme.LIGHT
else:
self.stage_option_menu_var_real = self.stage_option_menu_var.get().strip().lower()
if self.stage_option_menu_var.get().strip().lower() == Theme.LIGHT.value:
self.stage_option_menu_var_real = Theme.LIGHT
else:
self.stage_option_menu_var_real = Theme.DARK
theme_title_bar(self, self.stage_option_menu_var_real)
theme_title_bar(self.master, self.stage_option_menu_var_real)
def stage_theme_validate(self):
if self.stage_option_menu_var.get().strip().lower() == "auto":
if self.stage_option_menu_var.get().strip().lower() == Theme.AUTO.value:
configSet(["dark_mode_auto"], True)
else:
configSet(["dark_mode_auto"], False)
if self.stage_option_menu_var.get().strip().lower() == "dark":
if self.stage_option_menu_var.get().strip().lower() == Theme.DARK.value:
configSet(["dark_mode"], True)
else:
configSet(["dark_mode"], False)