CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Update theme while running?

Open Jodus-Melodus opened this issue 1 year ago • 6 comments

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.

Jodus-Melodus avatar Jun 17 '24 11:06 Jodus-Melodus

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.

teijiIshida avatar Jun 17 '24 12:06 teijiIshida

Yes thank you.

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

Jodus-Melodus avatar Jun 17 '24 18:06 Jodus-Melodus

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

teijiIshida avatar Jun 18 '24 15:06 teijiIshida

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"
}

Jodus-Melodus avatar Jun 19 '24 08:06 Jodus-Melodus

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.

teijiIshida avatar Jun 19 '24 13:06 teijiIshida

Yeah, I noticed. Thank you.

Jodus-Melodus avatar Jun 19 '24 15:06 Jodus-Melodus