About the Author |
|
xiii | |
About the Technical Reviewers |
|
xv | |
Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
Chapter 1 Getting Started with PyQt |
|
1 | (12) |
|
|
1 | (2) |
|
|
2 | (1) |
|
|
3 | (1) |
|
Installing Python 3 and PyQt6 |
|
|
3 | (2) |
|
Checking Your Version of Python |
|
|
4 | (1) |
|
|
4 | (1) |
|
Introduction to User Interfaces |
|
|
5 | (2) |
|
What Is a Graphical User Interface? |
|
|
5 | (1) |
|
Concepts for Creating Good Interface Design |
|
|
6 | (1) |
|
Creating Your First GUI: An Empty Window |
|
|
7 | (4) |
|
Explanation for Creating an Empty Window |
|
|
8 | (3) |
|
|
11 | (2) |
Chapter 2 Building a Simple GUI |
|
13 | (12) |
|
|
13 | (5) |
|
Explanation for Using QLabel |
|
|
14 | (4) |
|
Project 2.1 - User Profile GUI |
|
|
18 | (6) |
|
Designing the User Profile GUI |
|
|
19 | (1) |
|
Explanation for the User Profile GUI |
|
|
20 | (4) |
|
|
24 | (1) |
Chapter 3 Adding More Functionality with Widgets |
|
25 | (38) |
|
Event Handlers and Signals and Slots |
|
|
25 | (1) |
|
|
26 | (5) |
|
Explanation for Using QPushButton |
|
|
27 | (4) |
|
|
31 | (3) |
|
Explanation for Using QLineEdit |
|
|
31 | (3) |
|
|
34 | (4) |
|
Explanation for Using QCheckBox |
|
|
35 | (3) |
|
|
38 | (6) |
|
|
39 | (1) |
|
Explanation for Using QMessageBox |
|
|
39 | (5) |
|
Project 3.1 - Login GUI and Registration Dialog |
|
|
44 | (17) |
|
Designing the Login GUI and Registration Dialog |
|
|
46 | (1) |
|
Explanation for Creating the Login GUI |
|
|
47 | (8) |
|
Explanation for Creating the Main Window |
|
|
55 | (1) |
|
Explanation for Creating the Registration Dialog |
|
|
56 | (5) |
|
|
61 | (2) |
Chapter 4 Learning About Layout Management |
|
63 | (42) |
|
Using Layout Managers in PyQt |
|
|
64 | (1) |
|
|
65 | (1) |
|
Horizontal and Vertical Layouts with Box Layouts |
|
|
66 | (7) |
|
Explanation for QHBoxLayout |
|
|
66 | (3) |
|
Explanation for QVBoxLayout |
|
|
69 | (4) |
|
|
73 | (6) |
|
Explanation for Nested Layouts |
|
|
74 | (5) |
|
Arranging Widgets in Grids with QGridLayout |
|
|
79 | (8) |
|
Explanation for QGridLayout |
|
|
80 | (7) |
|
Building Forms with QFormLayout |
|
|
87 | (8) |
|
Explanation for QFormLayout |
|
|
88 | (7) |
|
Managing Pages with QStackedLayout |
|
|
95 | (6) |
|
Explanation for QStackedLayout |
|
|
97 | (4) |
|
Additional Tips for Managing Space |
|
|
101 | (3) |
|
Explanation for Managing Space |
|
|
102 | (2) |
|
|
104 | (1) |
Chapter 5 Menus, Toolbars, and More |
|
105 | (56) |
|
Common Practices for Creating Menus |
|
|
106 | (1) |
|
Creating a Simple Menu Bar |
|
|
106 | (5) |
|
Explanation for Creating a Menu Bar |
|
|
107 | (4) |
|
Using Icons and the Qlcon Class |
|
|
111 | (5) |
|
Explanation for Using Icons |
|
|
112 | (3) |
|
Setting the Central Widget |
|
|
115 | (1) |
|
Built-in Dialog Classes in PyQt |
|
|
116 | (6) |
|
|
116 | (1) |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
119 | (2) |
|
|
121 | (1) |
|
Project 5.1 - Rich Text Notepad GUI |
|
|
122 | (11) |
|
Designing the Rich Text Notepad GUI |
|
|
123 | (1) |
|
Explanation for the Rich Text Notepad GUI |
|
|
123 | (10) |
|
Expanding the Features in a Main Window |
|
|
133 | (9) |
|
Explanation for Expanding the Features |
|
|
134 | (8) |
|
Project 5.2 - Simple Photo Editor GUI |
|
|
142 | (17) |
|
Designing the Photo Editor GUI |
|
|
143 | (1) |
|
Explanation for the Photo Editor GUI |
|
|
143 | (16) |
|
|
159 | (2) |
Chapter 6 Styling Your GUIs |
|
161 | (40) |
|
|
161 | (2) |
|
Changing the Default Style |
|
|
162 | (1) |
|
Modifying Widget Appearances |
|
|
163 | (12) |
|
Using HTML to Change the Look of Text |
|
|
164 | (3) |
|
Using Qt Style Sheets to Change the Look of Widgets |
|
|
167 | (2) |
|
Explanation for Using "Inline" Qt Style Sheets |
|
|
169 | (3) |
|
Explanation for Using "Embedded" Qt Style Sheets |
|
|
172 | (3) |
|
Organizing Widgets with Containers and Tabs |
|
|
175 | (7) |
|
|
176 | (1) |
|
|
176 | (1) |
|
|
177 | (1) |
|
Explanation for Using Containers and Tabs |
|
|
177 | (5) |
|
Project 6.1 - Food Ordering GUI |
|
|
182 | (16) |
|
Design the Food Ordering GUI |
|
|
184 | (1) |
|
Explanation for the Food Ordering GUI |
|
|
185 | (13) |
|
|
198 | (1) |
|
|
199 | (2) |
Chapter 7 Handling Events in PyQt |
|
201 | (16) |
|
|
201 | (2) |
|
|
202 | (1) |
|
Using Event Handlers to Handle Events |
|
|
202 | (1) |
|
Difference Between Signals and Slots and Event Handlers |
|
|
203 | (1) |
|
|
203 | (2) |
|
Explanation for Handling Key Events |
|
|
204 | (1) |
|
|
205 | (6) |
|
Explanation for Handling Mouse Events |
|
|
207 | (4) |
|
|
211 | (5) |
|
Explanation for Creating Custom Signals |
|
|
212 | (4) |
|
|
216 | (1) |
Chapter 8 Creating GUIs with Qt Designer |
|
217 | (42) |
|
Getting Started with Qt Designer |
|
|
218 | (8) |
|
|
218 | (1) |
|
Exploring Qt Designer's User Interface |
|
|
219 | (6) |
|
Qt Designer's Editing Modes |
|
|
225 | (1) |
|
Creating an Application in Qt Designer |
|
|
226 | (1) |
|
|
227 | (27) |
|
Explanation for the Keypad GUI |
|
|
228 | (26) |
|
Extra Tips for Using Qt Designer |
|
|
254 | (4) |
|
Setting Up Main Windows and Menus |
|
|
254 | (3) |
|
Displaying Images in Qt Designer |
|
|
257 | (1) |
|
Adding Style Sheets in Qt Designer |
|
|
257 | (1) |
|
|
258 | (1) |
Chapter 9 Working with the Clipboard |
|
259 | (14) |
|
|
259 | (6) |
|
Explanation for Using QClipboard |
|
|
261 | (4) |
|
Project 9.1 - Sticky Notes GUI |
|
|
265 | (7) |
|
Explanation for the Sticky Notes GUI |
|
|
267 | (5) |
|
|
272 | (1) |
Chapter 10 Presenting Data in PyQt |
|
273 | (26) |
|
Quickly Handling Data in PyQt |
|
|
273 | (1) |
|
|
274 | (5) |
|
Explanation for Using QListWidget |
|
|
275 | (4) |
|
|
279 | (4) |
|
Explanation for Drag and Drop |
|
|
280 | (3) |
|
|
283 | (10) |
|
Explanation for Using QTableWidget |
|
|
284 | (9) |
|
|
293 | (4) |
|
Explanation for Using QTreeWidget |
|
|
294 | (3) |
|
|
297 | (2) |
Chapter 11 Graphics and Animation in PyQt |
|
299 | (42) |
|
Introduction to the QPainter Class |
|
|
300 | (14) |
|
Explanation for Using the QPainter Class |
|
|
301 | (13) |
|
Project 11.1 - Painter GUI |
|
|
314 | (1) |
|
Explanation for the Painter GUI |
|
|
315 | (14) |
|
Creating the Canvas Class |
|
|
316 | (6) |
|
Creating the Painter GUI's MainWindow Class |
|
|
322 | (5) |
|
Animating Scenes with QPropertyAnimation |
|
|
327 | (2) |
|
Explanation for Animating Scenes |
|
|
329 | (5) |
|
Introduction to Animating Widgets |
|
|
334 | (1) |
|
Explanation for Animating Widgets |
|
|
335 | (5) |
|
|
340 | (1) |
Chapter 12 Creating Custom Widgets |
|
341 | (18) |
|
Project 12.1 - RGB Slider Custom Widget |
|
|
341 | (15) |
|
PyQt's Image Handling Classes |
|
|
343 | (1) |
|
|
344 | (1) |
|
Explanation for the RGB Slider Widget |
|
|
345 | (11) |
|
|
356 | (2) |
|
Explanation for the RGB Slider Demo |
|
|
357 | (1) |
|
|
358 | (1) |
Chapter 13 Working with Qt Quick |
|
359 | (36) |
|
Outlining QtQuick and QML |
|
|
360 | (6) |
|
|
362 | (1) |
|
Introduction to the QML Language and Syntax |
|
|
363 | (3) |
|
Building and Running QML Components |
|
|
366 | (21) |
|
Creating and Loading QML Components |
|
|
367 | (6) |
|
Creating Reusable Components |
|
|
373 | (3) |
|
|
376 | (4) |
|
Building and Loading QML Windows |
|
|
380 | (7) |
|
Using Transformations to Animate Objects |
|
|
387 | (7) |
|
Explanation for Simple Transformations |
|
|
388 | (2) |
|
Explanation for Using Transformations to Animate Objects |
|
|
390 | (4) |
|
|
394 | (1) |
Chapter 14 Introduction to Handling Databases |
|
395 | (42) |
|
|
395 | (1) |
|
Introduction to ModelNiew Programming |
|
|
396 | (8) |
|
The Components of the ModelNiew Architecture |
|
|
396 | (2) |
|
|
398 | (2) |
|
Explanation for Introduction to ModelNiew |
|
|
400 | (4) |
|
Working with SQL Databases in PyQt |
|
|
404 | (3) |
|
|
404 | (3) |
|
Project 14.1 -Account Management GUI |
|
|
407 | (29) |
|
Explanation for Working with the QtSql Module |
|
|
409 | (7) |
|
Explanation for Querying a Database with QSqlQuery |
|
|
416 | (3) |
|
Working with the QSqlTableModel Class |
|
|
419 | (4) |
|
Working with the QSqlRelationalTableModel Class |
|
|
423 | (5) |
|
Explanation for the Account Management GUI |
|
|
428 | (8) |
|
|
436 | (1) |
Chapter 15 Managing Threads |
|
437 | (14) |
|
Introduction to Threading |
|
|
437 | (3) |
|
|
438 | (1) |
|
Methods for Processing Long Events in PyQt |
|
|
439 | (1) |
|
Project 15.1 - File Renaming GUI |
|
|
440 | (10) |
|
|
441 | (1) |
|
Explanation for File Renaming GUI |
|
|
441 | (9) |
|
|
450 | (1) |
Chapter 16 Extra Projects |
|
451 | (52) |
|
Project 16.1 - Directory Viewer GUI |
|
|
452 | (4) |
|
Explanation for the Directory Viewer GUI |
|
|
453 | (3) |
|
Project 16.2 - Camera GUI |
|
|
456 | (8) |
|
Explanation for the Camera GUI |
|
|
458 | (6) |
|
Project 16.3 - Simple Clock GUI |
|
|
464 | (3) |
|
Explanation for the Clock GUI |
|
|
465 | (2) |
|
Project 16.4 - Calendar GUI |
|
|
467 | (6) |
|
Explanation for the Calendar GUI |
|
|
468 | (5) |
|
Project 16.5 - Hangman GUI |
|
|
473 | (11) |
|
Explanation for the Hangman GUI |
|
|
475 | (9) |
|
Project 16.6 - Web Browser GUI |
|
|
484 | (13) |
|
Explanation for Web Browser GUI |
|
|
486 | (11) |
|
Project 16.7 - Tri-state QComboBox |
|
|
497 | (1) |
|
Explanation for the Tri-state QComboBox |
|
|
498 | (3) |
|
|
501 | (2) |
Appendix: Reference Guide for PyQt6 |
|
503 | (30) |
|
|
503 | (1) |
|
|
504 | (25) |
|
Classes for Building a GUI Window |
|
|
505 | (4) |
|
|
509 | (2) |
|
|
511 | (1) |
|
|
512 | (2) |
|
|
514 | (8) |
|
|
522 | (2) |
|
|
524 | (2) |
|
|
526 | (3) |
|
|
529 | (1) |
|
|
529 | (3) |
|
|
532 | (1) |
|
|
532 | (1) |
Index |
|
533 | |