In a project, I am trying to change the colour template of my project from a list of pre-loaded .json themes saved to a folder user_themes. The themes are Anthracite.json, Cobalt.json and Blue.json. A drop-down menu is used to select the color and the template should load.
I tried this:
from customtkinter import CTkLabel, CTkButton, CTkOptionMenu, set_default_color_theme, CTk
root = CTk()
root.geometry("400x400")
def click():
CTkLabel(root, text="Here is some text").pack(pady=20)
def new_color_theme(nct: str):
print(nct)
set_default_color_theme(f"user_themes/{nct}.json")
btn = CTkButton(root, text="Click me", command=click).pack(pady=20)
lst = ["Anthracite", "Cobalt", "Blue"]
menu = CTkOptionMenu(root, values=lst, command=new_color_theme).pack(pady=20)
root.mainloop()
But this is not working. The theme is getting printed but is not reflected in the window. What could be the reason for this and any suggestions to correct it?
1