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 towards the top of our GUI module:

    from threading import Thread     from queue import Queue

That gets us started.

Next, we create a queue instance:

    def use_queues(self):         gui_queue = Queue()                    # create queue instance         print(gui_queue)                       # print instance

We call the method within our button click event:

    # Button callback    def click_me(self):         self.action.configure(text='Hello ' + self.name.get())        self.create_thread()        self.use_queues()
In the preceding code, we create a local Queue instance that is only accessible within this method. If we wish to access this queue from other places, we have to turn it into ...

Get Python GUI Programming Cookbook - Second 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.