Wire-Py/testtheme.py

28 lines
729 B
Python
Raw Normal View History

import tkinter as tk
from tkinter import ttk
root = tk.Tk()
# Pack a big frame so, it behaves like the window background
big_frame = ttk.Frame(root)
big_frame.pack(fill="both", expand=True)
# Set the initial theme
root.tk.call("source", "TK-Themes/azure.tcl")
root.tk.call("set_theme", "light")
def change_theme():
# NOTE: The theme's real name is azure-<mode>
if root.tk.call("ttk::style", "theme", "use") == "azure-dark":
# Set light theme
root.tk.call("set_theme", "light")
else:
# Set dark theme
root.tk.call("set_theme", "dark")
# Remember, you have to use ttk widgets
button = ttk.Button(big_frame, text="Change theme!", command=change_theme)
button.pack()
root.mainloop()