Book Image

Tkinter GUI Programming by Example

Book Image

Tkinter GUI Programming by Example

Overview of this book

Tkinter is a modular, cross-platform application development toolkit for Python. When developing GUI-rich applications, the most important choices are which programming language(s) and which GUI framework to use. Python and Tkinter prove to be a great combination. This book will get you familiar with Tkinter by having you create fun and interactive projects. These projects have varying degrees of complexity. We'll start with a simple project, where you'll learn the fundamentals of GUI programming and the basics of working with a Tkinter application. After getting the basics right, we'll move on to creating a project of slightly increased complexity, such as a highly customizable Python editor. In the next project, we'll crank up the complexity level to create an instant messaging app. Toward the end, we'll discuss various ways of packaging our applications so that they can be shared and installed on other machines without the user having to learn how to install and run Python programs.
Table of Contents (18 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Using threads


When writing a Python application, all of the code will run in a single thread by default. This means that, as you read down a file, each line will be carried out one at a time. A piece of code cannot run if there is another piece above it which is executing a large task.

If we wanted to carry out multiple tasks at the same time, there are a couple of different ways we could go about doing so. One way is the use of a thread. When using a thread, the operating system will be able to quickly switch between two running pieces of code so quickly that it appears as if they are being executed at the same time. This means that if you have a function which takes a lot of processing, you are able to do multiple smaller tasks in the time it would take for that function to execute, thereby speeding up the overall process.

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...