-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathctk_lightdark.py
51 lines (34 loc) · 1.18 KB
/
ctk_lightdark.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from tkinter import *
import customtkinter
customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue") # Themes: blue (default), dark-blue, green
#root = Tk()
root = customtkinter.CTk()
root.title('Tkinter.com - CustomTkinter Light Dark Modes')
root.iconbitmap('images/codemy.ico')
root.geometry('700x450')
mode = "dark"
def change_colors(choice):
customtkinter.set_default_color_theme(choice)
def change():
global mode
if mode == "dark":
customtkinter.set_appearance_mode("light")
mode = "light"
# Clear text box
my_text.delete(0.0, END)
my_text.insert(END, "This is Light Mode...")
else:
customtkinter.set_appearance_mode("dark")
mode = "dark"
# Clear text box
my_text.delete(0.0, END)
my_text.insert(END, "This is Dark Mode...")
my_text = customtkinter.CTkTextbox(root, width=600, height=300)
my_text.pack(pady=20)
my_button = customtkinter.CTkButton(root, text="Change Light/Dark", command=change)
my_button.pack(pady=20)
colors = ["blue", "dark-blue", "green"]
my_option = customtkinter.CTkOptionMenu(root, values=colors, command=change_colors)
my_option.pack(pady=10)
root.mainloop()