@Aemyl is correct. Your problem is orphaned instances of Tk.
EDIT: I'm just using tk.Tk()
here but the solution should be the same. Just use the ctk
equivalents.
self.window = tk.Tk()
submit
:self.window.withdraw() # hides the window
self.window.quit() # exits the mainloop, but the instance is still live
print(self.entrypassword.get()) # add this line and you can see that the widgets are still accessible
show_main_window
you start another instance of Tk: window = tk.Tk()
logout
, you correctly kill the new instance: self.master.destory
LoginWindow
, which starts another instance of Tk. But the old instance is still there, orphaned, because you never killed it. You just exited the mainloop.Easy fix. Just replace
self.window.withdraw()
self.window.quit()
with
self.window.destroy() # no more orphaned instance
self.window.withdraw()
self.window.quit()
with
self.window.withdraw()
self.user_input.set('') # clear the Entry
Toplevel
in show_main_window
:window = tk.Tk()
with window = tk.Toplevel()
window.mainloop()
logout
, replacelogin = LoginWindow()
login.run()
with
self.master.master.deiconify()
logout
, though, or you'll still have that hidden window hanging around if you close with the [X]
button. Add this line just after creating the Toplevel window (in show_main_window
:window.protocol('WM_DELETE_WINDOW', self.exit)