Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

Why use a thread with a GUI application?

Graphical applications tend to execute everything in the main thread. This means that updates to its widgets happen in line with all other code that is currently executing.

As a result of this, any slow processing will often block the updating of the GUI. We can demonstrate this with a small example:

import tkinter as tkimport timewin = tk.Tk()win.geometry("200x150")counter = tk.IntVar()label = tk.Label(win, text="Ready to Work")counter_label = tk.Label(win, textvar=counter)

The example starts with a window which will contain a Label displaying the value of an IntVar.

We will be creating a button that increases the value stored in the IntVar, as well as another button which will simulate a very heavy ...

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

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content