CustomTkinter
CustomTkinter copied to clipboard
Customtkinter destroy
After the self.destroy()
code is activated, something appears on the console as in the picture. What is this?
it's pointing the same log in my project🤔
Here too, same message...
@galipyuksel can you post an example code where this appears for you?
link for the code: https://github.com/Aadhityaa04/Customtkinter-destroy---error/blob/2fa951752cbc9e26819997b1ef0e596a96fbcb77/playgrund.py
while clicking login button you will get the error. Maybe in line 25.
Your link is broken.
Sorry for the inconveniences Click this
This error is caused due to "after" jobs that have already been scheduled running but since the window has been destroyed it can't find those jobs. You should look at CTkToplevel to create new window.
@Aadhityaa04 you can not create multiple instances of CTk in the same process. Here is an example on how you would create a second window, which can only be opened once and which is written as a class:
import customtkinter
class ToplevelWindow(customtkinter.CTkToplevel):
def __init__(self, *args, closing_event=None, **kwargs):
super().__init__(*args, **kwargs)
self.protocol("WM_DELETE_WINDOW", self.closing)
self.geometry("500x300")
self.closing_event = closing_event
self.label = customtkinter.CTkLabel(self, text="ToplevelWindow")
self.label.pack(padx=20, pady=20)
def closing(self):
self.destroy()
if self.closing_event is not None:
self.closing_event()
class App(customtkinter.CTk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.geometry("500x400")
self.button_1 = customtkinter.CTkButton(self, text="Open CTkToplevel", command=self.open_toplevel)
self.button_1.pack(side="top", padx=40, pady=40)
self.toplevel_window = None
def open_toplevel(self):
if self.toplevel_window is None: # create toplevel window only if not already open
self.toplevel_window = ToplevelWindow(self, closing_event=self.toplevel_close_event)
def toplevel_close_event(self):
self.toplevel_window = None
if __name__ == "__main__":
app = App()
app.mainloop()
If you follow this template there shouldn't be any invalid command name
logs. Personally I never experienced them...