Answer the question
In order to leave comments, you need to log in
How to display a graphical window without blocking the main console thread?
In addition to the main flow of the Python program, I want to display a graphical warning window:
from datetime import datetime
import threading
from time import sleep
from tkinter import *
def show_notification_window():
root = Tk()
root.geometry("300x300")
warning_message = Message(root, text="Cthulhu fhtagn!")
warning_message.pack()
root.mainloop()
while True:
print(datetime.now().strftime("%H:%M:%S"))
gui_thread = threading.Thread(target=show_notification_window())
gui_thread.start()
sleep(1)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question