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

@@ -3,25 +3,27 @@ import sys
import sv_ttk
from distutils.version import StrictVersion as Version
from os import system
from tkinter import Tcl, Toplevel
from tkinter import Misc, Tcl, Toplevel
from typing import Literal, Union
from ttkthemes import ThemedTk
from classes.enums import Theme
if sys.platform.startswith("win"):
from ctypes import byref, c_int, sizeof, windll
def theme_title_bar(window: Union[ThemedTk, Toplevel], mode: Literal["dark", "light"]) -> None:
def theme_title_bar(window: Union[ThemedTk, Toplevel, Misc], mode: Literal[Theme.DARK, Theme.LIGHT]) -> None:
"""
MORE INFO:
https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
"""
if mode == "dark":
if mode.value == "dark":
value = 1
#window.configure(background="#1c1c1c")
elif mode == "light":
elif mode.value == "light":
value = 0
#window.configure(background="#ffffff")
else:
@@ -29,7 +31,7 @@ def theme_title_bar(window: Union[ThemedTk, Toplevel], mode: Literal["dark", "li
try:
sv_ttk.set_theme(mode)
sv_ttk.set_theme(mode.value)
window.update()