Skip to content

Instantly share code, notes, and snippets.

@comigor
Created June 21, 2018 15:39
Show Gist options
  • Save comigor/e77291b1ab7507837315a4add64fbdb8 to your computer and use it in GitHub Desktop.
Save comigor/e77291b1ab7507837315a4add64fbdb8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import tkinter as tk
from tkinter import simpledialog, messagebox
import threading, queue, time
root = tk.Tk()
root.withdraw()
thread_queue = queue.Queue()
def show_error(error):
messagebox.showerror('ERROR', error, parent = root)
def main(thread_queue):
while 1:
print("Infinite Loop")
time.sleep(3)
print("Infinite Loop2")
thread_queue.put({ 'call': 'show_error', 'error': 'porra' })
time.sleep(5)
def probe_for_message():
try:
res = thread_queue.get(0)
if res['call'] == 'show_error':
show_error(res['error'])
except queue.Empty:
pass
root.after(500, probe_for_message)
if __name__ == "__main__":
main_thread = threading.Thread(target = main, args=(thread_queue, ))
main_thread.start()
root.after(500, probe_for_message)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment