How to do it...

In order to create queues in Python, we have to import the Queue class from the queue module. Add the following statement toward the top of the GUI module:

  1. Open GUI_multiple_threads_starting_a_thread.py and save it as GUI_queues.py.
  2. Make the following changes to the code:
from threading import Thread from queue import Queue
  1. Add the following method:
def use_queues(self):     gui_queue = Queue()        # create queue instance     print(gui_queue)           # print instance
  1. Modify the click_me method:
# Button callbackdef click_me(self):     self.action.configure(text='Hello ' + self.name.get())    self.create_thread()    self.use_queues()
  1. Run the preceding code and observe the output as illustrated in the following screenshot:
  1. Modify use_queues ...

Get Python GUI Programming Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.