In this video I’ll show you how to create your own Custom Color Themes for CustomTkinter and Python.
CustomTkinter comes with three color themes; blue, dark-blue, and green.
But you can create as many other themes as you want by creating a theme JSON file. I’ll show you how to do it in this video…
Python Code: ctk_customcolor.py
(Github Code)
from tkinter import * import customtkinter customtkinter.set_appearance_mode("dark") # Modes: system (default), light, dark customtkinter.set_default_color_theme("themes/red.json") # Themes: blue (default), dark-blue, green #root = Tk() root = customtkinter.CTk() root.title('Tkinter.com - CustomTkinter Custom Color Themes') root.iconbitmap('images/codemy.ico') root.geometry('700x550') 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) my_progress = customtkinter.CTkProgressBar(root, orientation="horizontal") my_progress.pack(pady=20) root.mainloop()
Add comment