How it works...

In the callProgressBarTwoThreads.pyw file, there are two classes: one is the main class, called the MyForm class, which basically interacts with the GUI form, and the second class is the myThread class, which creates and invokes two threads, which in turn update the two Progress Bar widgets used in the GUI. Recall, the two progress bars are defined in the GUI to represent progress in downloading a file and scanning for viruses.

When using threads in Python, the first step is to import Thread. The import threading statement imports Thread in the current script. After importing Thread, the second step is to subclass our class from the Thread class. Hence, our class called myThread inherits the Thread class.

In the main section ...

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