[Python] How can I pause my code until a toplevel window is destroyed?

Discussão em 'Python' iniciado por Stack, Maio 18, 2025.

  1. Stack

    Stack Membro Participativo

    I try to add Error-Messages to my code. Each of those I want to display in a separate tkinter Toplevel window. So far so good.

    But for this I need to pause my code after the Error-Window was created and wait until the user presses the "okay" button in the Error-Window to continue. Only then the code is allowed to go on.

    The creation of the Error-Window I have problems with is within the mainloop of another tkinter window. Latter can not be destroyed without huge problems. Does anyone have a solution for me? Am I maybe committing a sin against the python-god? Can I pause a mainloop?

    I tried wait_window(win) (btw: what does it do? It doesn't seem to work as i understood it. Isn't it supposed to be waiting for the given window to be destroyed?)

    Also wait() didn't work for me.

    My coding senses tell me it has something to do with the mainloop within a mainloop. The code regarding is unfortunately way to long to post it here and a recreation with a sample would be a huge trouble. I hope my description is specific enough.

    Continue reading...

Compartilhe esta Página