This PyQt tutorial helps you develop beautiful GUI applications from scratch with PyQt6.
What’ll you learn
- Create beautiful desktop applications using PyQt6.
- Understand the core concepts of PyQt6 including the event loop, slots and signal, and widgets.
- Use the Qt Designer tool.
Who this PyQt tutorial is for
We create this PyQt tutorial for intermediate Python programmers who want to make powerful and beautiful desktop applications. We assume that you have been working with Python and understanding Python object-oriented programming.
Section 1. Getting Started
This section helps you get started with PyQt by developing the first but famous program that shows the Hello World message and helps you understand how PyQt works under the hood.
- PyQt Hello World – show you how to create a PyQt program that displays the
hello world
message on a window. - Signals & Slots – explain how PyQt uses signals & slots to allow objects to communicate with each other.
Section 2. Basic Widgets
In this section, you’ll learn about the basic widgets including QLabel, QPushButton, and QLineEdit.
- QLabel – display a text or an image.
- QPushButton – create a push button or toggle button.
- QLineEdit – show you how to create a single-line text entry widget.
Section 3. Layout Management
In this section, you’ll learn how to use Qt layout management to place and arrange widgets in the application window.
- QHBoxLayout – learn how to arrange widgets horizontally from left to right.
- QVBoxLayout – show you how to arrange widgets vertically from top to bottom.
- QGridLayout – place widgets in uniform rows and columns.
- QFormLayout – show you how to arrange widgets on data-entry forms effectively.
Section 4. More PyQt Widgets
In this section, you’ll learn how to use other commonly used PyQt widgets such as checkbox, radio button, combobox, spinner, date edit, time edit, date and time edit, and slider.
- QCheckbox – create a checkbox.
- QRadioButton – show you how to create a radio button and radio button group.
- QCombobox – create a combobox.
- QSpinBox – learn how to create a spin box that spins through a set of incremental values.
- QDateEdit – create a widget for editing dates.
- QTimeEdit – create a widget for editing times.
- QDateTimeEdit – create a widget for editing both dates and times.
- QSlider – create a slider that controls a bounded value.
- QWidget – create a container that holds child widgets.
- QTabWidget – create a tab widget that groups related widgets into pages.
- QGroupBox – create a group box with a title that groups related widgets.
- QTextEdit – create a widget that supports multiline text editing.
- QProgressBar – create a progress bar widget.
Section 5. Message Boxes & Dialogs
This section introduces to you the message boxes, input dialogs, and file dialogs so that you can create more interactive applications.
- QMessageBox – show you how to create common message boxes including information, warning, critical, and question.
- QInputDialog – learn how to create a simple dialog to get input from the user.
- QFileDialog – guide you on how to create a file dialog that selects one or more files or a directory.
Section 6. Main Window, Menus, Toolbars, and Status Bars
This section shows you how to create the main window and other commonly used widgets like menu bars, toolbars, and status bars. We’ll develop a simple text editor program.
- QMainWindow – show you how to create the main window that supports the menu bars, toolbars, and status bars.
- QMenu – show you how to create a menu bar and add menu items to the menu bar.
- QToolBar – learn how to create a toolbar and add it to the main window.
- QStatusBar – guide you on how to create a status bar for the main window.
- QDockWidget – show you how to create a dock widget.
Section 7. List, Table, and Tree Widgets
This section introduces to you the widgets for presenting data including list, table, and tree widgets.
- QListWidget – show you how to use the list widget.
- QTableWidget – learn how to use the table widget to display tabular data.
- QTreeWidget – guide you on how to present hierarchical data on a tree widget.
Section 8. Qt Designer
- Qt Designer – show you how to design user interfaces using Qt Designer.
Section 9. PyQt & Concurrency
This section shows you how to create a responsive PyQt application using multithreading techniques.
- QThread – show you how to use QThread class to offload a long-running operation to a worker thread from the main thread.
- QThreadPool – learn how to use the QThreadPool and QRunnable classes to manage and recycle worker threads automatically.
Section 10. Theming
This section guides you on how to customize the Qt widgets using Qt style sheets, themes, and icons.
- Qt Style Sheets – show you how to use the Qt Style Sheets (QSS) to customize the appearance of the widgets.
Section 11. PyQt Model/View Pattern
- Model/view pattern – learn about model/view pattern in PyQt.
Section 12. Package & distribute PyQt apps
- PyQt to EXE – show you how to convert a PyQt program to an executable file using PyInstaller.