Skip to content

Commit

Permalink
add theme option
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpsankalpa committed Feb 27, 2024
1 parent 9b11601 commit 528c582
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Binary file added __pycache__/theme.cpython-312.pyc
Binary file not shown.
30 changes: 30 additions & 0 deletions theme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# themes.py

THEMES = {
"light": {
"bg": "white",
"fg": "black",
"button_bg": "#eeeeee", # Light gray
"button_fg": "black",
},
"dark": {
"bg": "#2d2d2d", # Dark gray
"fg": "white",
"button_bg": "#555555", # Darker gray
"button_fg": "white",
},
}

def apply_theme(root, theme):
selected_theme = THEMES.get(theme, THEMES["light"]) # Default to light theme if theme not found
root.configure(bg=selected_theme["bg"])

for widget in root.winfo_children():
apply_widget_theme(widget, selected_theme)


def apply_widget_theme(widget, theme):
if widget.winfo_class() == "Button":
widget.configure(bg=theme["button_bg"], fg=theme["button_fg"])
else:
widget.configure(bg=theme["bg"], fg=theme["fg"])

0 comments on commit 528c582

Please sign in to comment.