Moved print to event loop

This commit is contained in:
MikeTheWatchGuy 2019-09-05 10:27:19 -04:00
parent 221e0ab88e
commit 221d376f10
1 changed files with 2 additions and 3 deletions

View File

@ -51,11 +51,10 @@ def worker_thread(thread_name, run_freq, gui_queue):
:param gui_queue: Queue used to communicate with the GUI :param gui_queue: Queue used to communicate with the GUI
:return: :return:
""" """
print('Starting thread - {} that runds every {} ms'.format(thread_name, run_freq)) print('Starting thread - {} that runs every {} ms'.format(thread_name, run_freq))
for i in itertools.count(): # loop forever, keeping count in i as it loops for i in itertools.count(): # loop forever, keeping count in i as it loops
time.sleep(run_freq/1000) # sleep for a while time.sleep(run_freq/1000) # sleep for a while
gui_queue.put('{} - {}'.format(thread_name, i)) # put a message into queue for GUI gui_queue.put('{} - {}'.format(thread_name, i)) # put a message into queue for GUI
print('..')
###### ## ## #### ###### ## ## ####
## ## ## ## ## ## ## ## ## ##
@ -95,7 +94,7 @@ def the_gui(gui_queue):
if message: if message:
window.Element('_OUTPUT_').Update(message) window.Element('_OUTPUT_').Update(message)
window.Refresh() # do a refresh because could be showing multiple messages before next Read window.Refresh() # do a refresh because could be showing multiple messages before next Read
print(message)
# if user exits the window, then close the window and exit the GUI func # if user exits the window, then close the window and exit the GUI func
window.Close() window.Close()