Home > Enterprise >  Tkinter Python: How to continue running script without closing the messagebox popup
Tkinter Python: How to continue running script without closing the messagebox popup

Time:08-01

I have a doubt, how can I continue running the script without closing a messagebox from tkinter? Or show multiple messageboxes at the same time An example:

from tkinter import messagebox as MB
aux = 0

def scrpt():
    global aux
    #the script stops here ⬇️
    MB.showinfo(title="Simple Program", message="aux= " str(aux))
    #the code below isnt ejecuted if i didnt accept or close the above popup ⬆️
    aux  = 1
while True:
    scrpt()

I want to know if there is a way to continue running the script without closing the tkinter messagebox popup.

CodePudding user response:

I don't think that is possible with message box because I tried it with many ways but in vain, however …

you can do it by using Toplevel() class:

from tkinter import *

for i in range(0, 100):
    a = Toplevel()
    Label(a, text=str(i)).pack()

mainloop()

The problem is by closing one window all will close too, you can do this so it won't close together:

for i in range(0,100):
    a= Tk()

mainloop()
  • Related