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