i have again an issue, that i did not figured out why.. All needed code is summarized in this screenshot: Code
The part in "pixela_brain.py" where the two print statements are, is the problem zone:
- The print("Before Opening UICreateUser") is shown as expected
- The print("x is clicked") in "create_user.py" is shown as expected too
- But after "self.destroy()" in "create_user.py" should the print("After Closing UICreateUser") printed as well, but it do not.
- Only after closing the Main Tk Window the second print-statement is executing.
Why is that? i would expect, that the methode "create_user(self)" should executed to the end after killing the mainloop from UICreateUser Toplevel-Window.
Here is tho code for copy/paste purposes:
main.py
from ui_root import UiRoot
app = UiRoot()
pixela_brain.py
from popup_windows.create_user import UiCreateUser
class PixelaBrain:
def __init__(self):
pass
def create_user(self):
print("Before Opening UICreateUser")
self.new_user = UiCreateUser()
print("After Closing UICreateUser")
ui_root.py
from tkinter import Tk, Button
from pixela_brain import PixelaBrain
class UiRoot(Tk):
def __init__(self):
super().__init__()
self.brain = PixelaBrain()
self.button = Button(self, text="Button", command=self.click)
self.button.pack()
self.mainloop()
def click(self):
self.brain.create_user()
create_user.py
from tkinter import Toplevel
class UiCreateUser(Toplevel):
def __init__(self):
super().__init__()
self.protocol("WM_DELETE_WINDOW", self.click_x)
self.grab_set()
self.mainloop()
def click_x(self):
print("x is clicked")
self.destroy()
Thanks a lot in advance.