It possible to update theme in real time? #2373
Replies: 2 comments 3 replies
-
Hello @purplesmileguy. If I understand your question, it's a limitation of CustomTkinter. There is a lot of heavy lifting involved, in order to change themes, after an application has started. You would need to destroy and re-create all your widgets after changing themes. This would require that you design your application around the ability, as you also need to take into account the session state (i.e. any user inputs made etc). |
Beta Was this translation helpful? Give feedback.
-
You would surely need a whole bunch of wrapper classes; the widgets have a variety (varied compositions) of attributes. Also, some of the widgets are compound widgets, made up of more than one CustomTkinter widget (e.g. CTkTabView, CTkScrollableFrame, CTkTextbox). These may add extra challenges (e.g issue #1803 - although this example may be fixed now). |
Beta Was this translation helpful? Give feedback.
-
Its only apply to new window after the change of theme
`script_dir = os.path.dirname(os.path.abspath(file))
#Path at the folder of main.py
NightTrain = os.path.join(script_dir, "NightTrain.json")
current_theme = "NightTrain"
NeonBanana = os.path.join(script_dir, "NeonBanana.json")
customtkinter.set_ctk_parent_class(tkinterDnD.Tk)
customtkinter.deactivate_automatic_dpi_awareness()
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
customtkinter.set_default_color_theme(NightTrain) # Themes: "blue" (standard), "green", "dark-blue"
def change_theme():
global current_theme #Global theme
username1 = "user" + str(random.randint(0, 9999))
save_file = "data.json"`
Beta Was this translation helpful? Give feedback.
All reactions