Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

The Queue object

Python's queue.Queue is a first-in first-out (FIFO) data structure. Items can be placed into a Queue object using the put() method, and retrieved using the get() method. Let's take a look at the following example:

>>> from queue import Queue
>>> q = Queue()
>>> q.put('My item')
>>> q.get()
'My item'

This may not seem terribly exciting, but what makes Queue useful is that it has been specially designed to work safely as a channel for asynchronous communication between threads (programmers refer to this as thread-safe). One thread can place messages on queue, and another can retrieve them and respond appropriately.

By default, get() will block until an item is received. This behavior can be altered by passing False as its first ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content