[Python] Python message box showing without stopping script

Discussão em 'Python' iniciado por Stack, Abril 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have an script that create numbers randomly, between 5 and 55, in a infinite loop. My goal is to show a message box when the number 55 is created. I have try easygui, tkinter, ctypes,... and I have been able to create the message box, but when this box appears the loop stops and it doesn't continue untill the user clicks de OK button. Is there a way to show a message box without stopping the script?

    I have been looking for information in forums but I haven't found someone with this problem, so I hope someone can help me.

    This is the part of the code with the loop:

    def contador():
    for x in range(1):
    aleatorio = random.randint(1,11)*5
    if aleatorio ==55:
    estado = "Red"
    ctypes.windll.user32.MessageBoxW(0, u"Error", u"Error", 0)
    elif aleatorio >=30:
    estado = "Red"

    else:
    estado = "Green"

    global t
    t = threading.Timer(15.0, contador)
    t.start()

    t = threading.Timer(15.0, contador)
    t.start()

    Continue reading...

Compartilhe esta Página