Improved naming and imports
This commit is contained in:
parent
46d02b4de5
commit
67f87e0830
@ -1,12 +1,15 @@
|
|||||||
|
from os import path
|
||||||
|
from tkinter import NW, E, N, S, W, messagebox, ttk
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import sv_ttk
|
import sv_ttk
|
||||||
from os import path
|
|
||||||
from tkinter import ttk, messagebox, N, S, W, E, NW
|
|
||||||
from ttkthemes import ThemedTk
|
from ttkthemes import ThemedTk
|
||||||
from modules.dark_titlebar import dark_title_bar
|
|
||||||
from modules.utils import configGet, use_dark_mode
|
|
||||||
from classes.window_config import WindowConfig
|
|
||||||
from classes.frames import FrameDevices, FrameSaves, FrameSettings
|
from classes.frames import FrameDevices, FrameSaves, FrameSettings
|
||||||
|
from classes.window_config import WindowConfig
|
||||||
|
from modules.theme_titlebar import theme_title_bar
|
||||||
|
from modules.utils import configGet, use_dark_mode
|
||||||
|
|
||||||
|
|
||||||
class App(ThemedTk):
|
class App(ThemedTk):
|
||||||
|
|
||||||
@ -32,7 +35,7 @@ class App(ThemedTk):
|
|||||||
|
|
||||||
if use_dark_mode():
|
if use_dark_mode():
|
||||||
self.configure(background="#1c1c1c")
|
self.configure(background="#1c1c1c")
|
||||||
dark_title_bar(self, mode="dark")
|
theme_title_bar(self, mode="dark")
|
||||||
sv_ttk.set_theme("dark")
|
sv_ttk.set_theme("dark")
|
||||||
else:
|
else:
|
||||||
sv_ttk.set_theme("light")
|
sv_ttk.set_theme("light")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from tkinter import ttk, NS, EW
|
from tkinter import EW, NS, ttk
|
||||||
|
|
||||||
from ttkthemes import ThemedTk
|
from ttkthemes import ThemedTk
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import time
|
|
||||||
import requests
|
|
||||||
from os import path
|
from os import path
|
||||||
from tkinter import ttk, messagebox, IntVar, Toplevel, N, S, W, E, END
|
from tkinter import END, E, IntVar, N, S, Toplevel, W, messagebox, ttk
|
||||||
from modules.dark_titlebar import dark_title_bar
|
|
||||||
from modules.utils import configGet, configSet, use_dark_mode
|
import requests
|
||||||
|
|
||||||
|
from modules.theme_titlebar import theme_title_bar
|
||||||
from modules.logger import logger
|
from modules.logger import logger
|
||||||
|
from modules.utils import configGet, configSet, use_dark_mode
|
||||||
|
|
||||||
|
|
||||||
class WindowConfig(Toplevel):
|
class WindowConfig(Toplevel):
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ class WindowConfig(Toplevel):
|
|||||||
self.focus_set()
|
self.focus_set()
|
||||||
|
|
||||||
if use_dark_mode() is True:
|
if use_dark_mode() is True:
|
||||||
dark_title_bar(self, "dark")
|
theme_title_bar(self, "dark")
|
||||||
|
|
||||||
self.columnconfigure(0, weight=1)
|
self.columnconfigure(0, weight=1)
|
||||||
self.columnconfigure(1, weight=3)
|
self.columnconfigure(1, weight=3)
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import ctypes
|
|
||||||
import os
|
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import tkinter
|
from ctypes import byref, c_int, sizeof, windll
|
||||||
from typing import Literal
|
|
||||||
from distutils.version import StrictVersion as Version
|
from distutils.version import StrictVersion as Version
|
||||||
|
from os import system
|
||||||
|
from tkinter import Tcl, Toplevel
|
||||||
|
from typing import Literal, Union
|
||||||
|
|
||||||
def dark_title_bar(window, mode: Literal["dark", "light"]):
|
from ttkthemes import ThemedTk
|
||||||
|
|
||||||
|
|
||||||
|
def theme_title_bar(window: Union[ThemedTk, Toplevel], mode: Literal["dark", "light"]) -> None:
|
||||||
"""
|
"""
|
||||||
MORE INFO:
|
MORE INFO:
|
||||||
https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute
|
||||||
@ -25,27 +28,27 @@ def dark_title_bar(window, mode: Literal["dark", "light"]):
|
|||||||
|
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
|
|
||||||
hwnd = ctypes.windll.user32.GetParent(window.winfo_id())
|
hwnd = windll.user32.GetParent(window.winfo_id())
|
||||||
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
|
||||||
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19
|
DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1 = 19
|
||||||
|
|
||||||
# try with DWMWA_USE_IMMERSIVE_DARK_MODE
|
# try with DWMWA_USE_IMMERSIVE_DARK_MODE
|
||||||
if ctypes.windll.dwmapi.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, ctypes.byref(ctypes.c_int(value)), ctypes.sizeof(ctypes.c_int(value))) != 0:
|
if windll.dwmapi.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, byref(c_int(value)), sizeof(c_int(value))) != 0:
|
||||||
|
|
||||||
# try with DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20h1
|
# try with DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20h1
|
||||||
ctypes.windll.dwmapi.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ctypes.byref(ctypes.c_int(value)), ctypes.sizeof(ctypes.c_int(value)))
|
windll.dwmapi.DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, byref(c_int(value)), sizeof(c_int(value)))
|
||||||
|
|
||||||
elif sys.platform == "darwin":
|
elif sys.platform == "darwin":
|
||||||
|
|
||||||
if value == 1:
|
if value == 1:
|
||||||
if Version(platform.python_version()) < Version("3.10"):
|
if Version(platform.python_version()) < Version("3.10"):
|
||||||
if Version(tkinter.Tcl().call("info", "patchlevel")) >= Version("8.6.9"): # Tcl/Tk >= 8.6.9
|
if Version(Tcl().call("info", "patchlevel")) >= Version("8.6.9"): # Tcl/Tk >= 8.6.9
|
||||||
os.system("defaults write -g NSRequiresAquaSystemAppearance -bool No")
|
system("defaults write -g NSRequiresAquaSystemAppearance -bool No")
|
||||||
# This command allows dark-mode for all programs
|
# This command allows dark-mode for all programs
|
||||||
else:
|
else:
|
||||||
if Version(platform.python_version()) < Version("3.10"):
|
if Version(platform.python_version()) < Version("3.10"):
|
||||||
if Version(tkinter.Tcl().call("info", "patchlevel")) >= Version("8.6.9"): # Tcl/Tk >= 8.6.9
|
if Version(Tcl().call("info", "patchlevel")) >= Version("8.6.9"): # Tcl/Tk >= 8.6.9
|
||||||
os.system("defaults delete -g NSRequiresAquaSystemAppearance")
|
system("defaults delete -g NSRequiresAquaSystemAppearance")
|
||||||
# This command reverts the dark-mode setting for all programs.
|
# This command reverts the dark-mode setting for all programs.
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
@ -1,7 +1,9 @@
|
|||||||
from json import JSONDecodeError, loads, dumps
|
from json import JSONDecodeError, dumps, loads
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import darkdetect
|
import darkdetect
|
||||||
|
|
||||||
|
|
||||||
def jsonLoad(filename):
|
def jsonLoad(filename):
|
||||||
"""Loads arg1 as json and returns its contents"""
|
"""Loads arg1 as json and returns its contents"""
|
||||||
with open(filename, "r", encoding='utf8') as file:
|
with open(filename, "r", encoding='utf8') as file:
|
||||||
|
Loading…
Reference in New Issue
Block a user