Skip to content

Commit

Permalink
more work on dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne-Weber authored and Windows200000 committed May 21, 2024
1 parent dbada57 commit 3ca39b3
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,7 @@ class SettingsPanel:
AUTOSTART_KEY: str = "HKCU/Software/Microsoft/Windows/CurrentVersion/Run"

def __init__(self, manager: GUIManager, master: ttk.Widget, root: tk.Tk):
self._manager = manager
self._root = root
self._twitch = manager._twitch
self._settings: Settings = manager._twitch.settings
Expand Down Expand Up @@ -1651,9 +1652,9 @@ def _get_autostart_path(self, tray: bool) -> str:
def change_theme(self):
self._settings.dark_theme = bool(self._vars["dark_theme"].get())
if self._settings.dark_theme:
set_theme(self._root, "dark")
set_theme(self._root, self._manager, "dark")
else:
set_theme(self._root, "light")
set_theme(self._root, self._manager, "light")

def update_autostart(self) -> None:
enabled = bool(self._vars["autostart"].get())
Expand Down Expand Up @@ -1943,11 +1944,6 @@ def __init__(self, twitch: Twitch):
style.configure("Link.TLabel", font=link_font, foreground="blue")
# end of style changes

if self._twitch.settings.dark_theme:
set_theme(root, "dark")
else:
set_theme(root, "light")

root_frame = ttk.Frame(root, padding=8)
root_frame.grid(column=0, row=0, sticky="nsew")
root.rowconfigure(0, weight=1)
Expand Down Expand Up @@ -2018,6 +2014,11 @@ def __init__(self, twitch: Twitch):
else:
self._root.after_idle(self._root.deiconify)

if self._twitch.settings.dark_theme:
set_theme(root, self, "dark")
else:
set_theme(root, self, "light")

# https://stackoverflow.com/questions/56329342/tkinter-treeview-background-tag-not-working
def _fixed_map(self, option):
# Fix for setting text colour for Tkinter 8.6.9
Expand Down Expand Up @@ -2156,14 +2157,48 @@ def print(self, message: str):
self.output.print(message)


def set_theme(root, name):
def set_theme(root, manager, name):
style = ttk.Style(root)
# Style options
match name:
case "dark":
style.configure('.', background='#2b2b2b', foreground='#ffffff')
case "light" | "default" | _ :
style.configure('.', background='#ffffff', foreground='#000000')
style.theme_use('alt')
style.configure('.', background="#181818", foreground="#ffffff")
style.configure("TButton", background="#181818")
style.map("TButton",
background=[("active", "#2b2b2b")],
foreground=[("pressed", "black")])
style.configure("TNotebook.Tab", background="#181818")
style.map("TNotebook.Tab",
background=[("selected", "#2b2b2b")])
style.configure("TCheckbutton", foreground="black")
style.map("TCheckbutton",
background=[('active', '#2b2b2b')])
style.configure("TLabelFrame", background="#181818")
manager.output._text.configure(bg="#181818")
manager.settings._exclude_list.configure(bg="#181818", fg="#ffffff")
manager.settings._priority_list.configure(bg="#181818", fg="#ffffff")



case "light" | "default" | _ : # TEMP RETURN VALUES
style.theme_use('vista')
style.configure('.', background="#ffffff", foreground="#000000")
style.configure("TButton", background="#ffffff")
style.map("TButton",
background=[("active", "#e0e0e0")],
foreground=[("pressed", "black")])
style.configure("TNotebook.Tab", background="#ffffff")
style.map("TNotebook.Tab",
background=[("selected", "#e0e0e0")])
style.configure("TCheckbutton", foreground="black")
style.map("TCheckbutton",
background=[('active', '#e0e0e0')])
style.configure("TLabelFrame", background="#ffffff")
manager.output._text.configure(bg="#ffffff")
manager.settings._exclude_list.configure(bg="#ffffff", fg="#000000")
manager.settings._priority_list.configure(bg="#ffffff", fg="#000000")


###################
# GUI MANAGER END #
Expand Down

0 comments on commit 3ca39b3

Please sign in to comment.