简体   繁体   中英

Tkinter Python: How to continue running script without close messagebox popup

i have a doubt, how can i continue running the script without closing a messagebox from tkinter? Or show multiple messagebox 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.

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM