TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
10.77k stars 1.03k forks source link

Update theme while running? #2475

Open Jodus-Melodus opened 2 weeks ago

Jodus-Melodus commented 2 weeks ago

Can I update or change the default theme while the program is running?

It could be a nice feature if there isn't such a feature.

teijiIshida commented 2 weeks ago

It's possible. One of the examples they provided (complex_example.py) let you change light, dark, and system theme while the app is running.

Jodus-Melodus commented 2 weeks ago

Yes thank you.

But I want to switch between custom themes. Themes that I created in a separate json file myself.

teijiIshida commented 2 weeks ago

I'm actually trying custom theme myself. You can read more here: https://customtkinter.tomschimansky.com/documentation/color/

Guide: https://www.youtube.com/watch?v=mMyZD8qcYtA

Jodus-Melodus commented 2 weeks ago

Thank you!

See, I'm working on an application with a separate settings.json file that handles all the settings including the theme. The user can change it while it is running and I want to update the theme accordingly.

I'm using this to set the theme when the application is being initialized, but it doesn't work when I use it to update the theme while the program is running.

ctk.set_default_color_theme(f"Themes/{settings['theme']}/theme.json")
settings = {
     "theme": "name of the theme"
}
teijiIshida commented 2 weeks ago

When you use set_default_color_theme, you'll have to reopen the app for it to take effect (that's just how the function works). Maybe there are other workarounds but it's pretty complex.

Jodus-Melodus commented 2 weeks ago

Yeah, I noticed. Thank you.