The column of "Quick Mastering PyQt5" has been compiled into a book and published!

First of all, thank you very much for your love and support for the "Quickly Mastering PyQt5" column! This column has now been compiled and published as a book titled "PyQt Programming Quick Start" .

The content of this book has been optimized in many aspects on the basis of the content of the column, the content is richer, the layout of knowledge points is more reasonable, and the code and explanation are more concise and easy to understand. For some problems that fans and friends often encounter when using PyQt , the author also gives solutions in the book. In addition, this book also explains in detail the usage and techniques of PyInstaller and Nuitka packaging. I believe this book will allow everyone to quickly get started with PyQt and feel the charm of PyQt .

​Book Errata

Readers please pay attention, two printing errors were found in the book.

1. The setsPlainText() in the table method introduction on page 38 should be setPlainText(), with an extra s.

2. In the text description on page 140, Qthread should be QThread.

For this I apologize, and these errors will be corrected in reprints. If you find other errors, readers can submit errata on the asynchronous community or private message me, thank you very much.

book purchase address

Tmall , Dangdang , JD.com , Asynchronous Community

book catalog

Chapter 1 PyQt Basics 1

1.1 Install PyQt 1

1.1.1 Installation on different systems 1

1.1.2 Verify that the installation is successful 3

1.2 Design a simple PyQt window 3

1.2.1 Program entry 3

1.2.2 Embed HTML code in PyQt program 4

1.2.3 Creating a window in a class 5

1.3 Layout management 6

1.3.1 Layout using the move() method 7

1.3.2 Vertical layout manager QVBoxLayout 8

1.3.3 Horizontal layout manager QHBoxLayout 9

1.3.4 Form layout manager QFormLayout 10

1.3.5 Grid layout manager QGridLayout 11

1.3.6 Layout nesting 12

1.4 Signals and slots 13

1.4.1 Understanding the signal and slot mechanism 13

1.4.2 One signal connected to one slot 14

1.4.3 A signal connected to multiple slots 17

1.4.4 Multiple signals connected to one slot 18

1.4.5 Signals and signal connections 19

1.4.6 Custom signal 20

1.5 Learn to use documents 22

1.5.1 Understanding the C++ code on the document 22

1.5.2 How to use the document 23

1.6 Chapter Summary 25

Chapter 2 Basic controls of PyQt 26

2.1 Label control QLabel 26

2.1.1 Display text 26

2.1.2 Display picture 27

2.1.3 Display animation 28

2.2 Message box control QMessageBox 30

2.2.1 Various types of message boxes 30

2.2.2 Interacting with message boxes 32

2.2.3 Write a message box with Chinese buttons 33

2.3 Text Box Control 34

2.3.1 Single-line text box control QLineEdit 34

2.3.2 Text edit box control QTextEdit 36

2.3.3 Text browser control QTextBrowser 38

2.4 Various button controls 39

2.4.1 Common button control QPushButton 39

2.4.2 Tool button control QToolButton 40

2.4.3 Radio Button Control QRadioButton 41

2.4.4 Check box button control QCheckBox 42

2.4.5 Drop-down box button control QComboBox 43

2.5 Controls related to numbers 45

2.5.1 LCD digital control QLCDNumber 45

2.5.2 Digital spin box control QSpinBox and QDoubleSpinBox 46

2.5.3 Slide bar control QSlider 47

2.5.4 Dashboard control QDial 48

2.6 Date-related controls 49

2.6.1 Calendar control QCalendarWidget 49

2.6.2 Date time control QDateTimeEdit 51

2.7 Timer control and progress bar control 53

2.7.1 Timer control QTimer 53

2.7.2 Progress bar control QProgressBar 54

2.8 Chapter Summary 55

Chapter 3 Advanced Controls for PyQt 56

3.1 Combo Box Controls and Toolbox Controls 56

3.1.1 Group box control QGroupBox 56

3.1.2 Toolbox control QToolBox 57

3.2 Scroll area control and scroll bar control 59

3.2.1 Scroll area control QScrollArea 59

3.2.2 Scroll bar control QScrollBar 61

3.3 More container controls 63

3.3.1 Split window control QSplitter 63

3.3.2 Tab page control QTabWidget 64

3.3.3 Stack control QStackedWidget 66

3.3.4 Multi-document area control QMdiArea 67

3.4 List View Control, Tree View Control, Table View Control 69

3.4.1 List view control QListView 70

3.4.2 Tree view control QTreeView 72

3.4.3 Table view control QTableView 73

3.5 Simplified version of list, tree and table view controls 75

3.5.1 Simplified version of the list view control QListWidget 75

3.5.2 Simplified version of tree view control QTreeWidget 76

3.5.3 Simplified version of the table view control QTableWidget 78

3.6 Various dialog controls 79

3.6.1 Color dialog control QColorDialog 79

3.6.2 Font dialog control QFontDialog 81

3.6.3 Input dialog control QInputDialog 82

3.6.4 File dialog control QFileDialog 84

3.7 Chapter Summary 86

Chapter 4 Deep Dive into Windows 87

4.1 Window properties 87

4.1.1 Window titles and icons 88

4.1.2 Window size and position 88

4.1.3 Other window properties 91

4.2 Window coordinates 93

4.2.1 Understanding coordinate systems 93

4.2.2 Components of a window 94

4.3 Window events 95

4.3.1 Window close event 95

4.3.2 Window resizing events 96

4.3.3 Keyboard events 97

4.3.4 Mouse Events 98

4.3.5 Drag and drop event 100

4.3.6 Draw Event 102

4.4 The main window class QMainWindow 103

4.4.1 Components of the main window 103

4.4.2 Docking window class QDockWidget 105

4.4.3 Menu bar class QMenuBar 107

4.4.4 Toolbar class QToolBar 108

4.4.5 Status bar class QStatusBar 110

4.4.6 Program startup screen class QSplashScreen 112

4.5 Chapter Summary 113

Chapter 5 Qt Designer 114

5.1 Installation and configuration 114

5.1.1 Install 114 on Windows system

5.1.2 Install 115 on macOS system

5.1.3 Install 115 on Ubuntu system

5.1.4 Configuring the designer in PyCharm 116

5.2 Understanding the Parts in the Designer Window 117

5.2.1 Control box 118

5.2.2 Object Viewer 118

5.2.3 Property editor 119

5.2.4 Menu bar and toolbar 119

5.3 Four editing modes 121

5.3.1 Layout mode 121

5.3.2 Editing signal and slot patterns 123

5.3.3 Editing the partnership schema 125

5.3.4 Edit Tab order mode 126

5.4 Login box development practice 127

5.4.1 Editing properties 127

5.4.2 Layout controls 129

5.4.3 Convert .ui file to .py file 130

5.4.4 Writing functional logic code 130

5.5 Chapter Summary 131

Chapter 6 Advanced PyQt Applications 132

6.1 Database 132

6.1.1 Database connection and shutdown 133

6.1.2 Executing SQL statements 134

6.1.3 The database model 136

6.2 Multithreading 139

6.2.1 Using QThread thread class 140

6.2.2 Get window data information in the thread 143

6.2.3 Writing a simple crawler program 144

6.3 Drawing and printing 146

6.3.1 Brush class QPen 146

6.3.2 Brush class QBrush 149

6.3.3 Drawing a rectangle on the window with the mouse 150

6.3.4 Printing 153

6.4 Animation 155

6.4.1 Property animation class QPropertyAnimation 155

6.4.2 Serial animation group class QSequentialAnimationGroup 158

6.4.3 Parallel animation group class QParallelAnimationGroup 160

6.4.4 Time axis class QTimeLine 162

6.5 Audio and Video 164

6.5.1 Sound class QSound 164

6.5.2 Sound effect class QSoundEffect 165

6.5.3 Media player class QMediaPlayer 166

6.6 Web page interaction 170

6.6.1 Understanding QWebEngineView 170

6.6.2 Making a simple browser 172

6.7 Network applications 175

6.7.1 QUdpSocket 175

6.7.2 QTcpSocket and QTcpServer 180

6.8 QSS 183

6.8.1 Install QSS Highlight Plugin 185

6.8.2 Basic rules 185

6.8.3 Types of selectors 187

6.8.4 Sub-controller 189

6.8.5 Pseudo-states 190

6.8.6 QSS third-party library 191

6.9 Internationalization 193

6.9.1 Using the translate() method 193

6.9.2 Making .ts files 194

6.9.3 Using Qt Linguist 196

6.9.4 Realize language switching function 198

6.10 Chapter Summary 199

Chapter 7 Graphics View Framework 200

7.1 Graphic primitive class QGraphicsItem 200

7.1.1 Standard primitives 200

7.1.2 Primitive hierarchy 203

7.1.3 Primitive Transformation 205

7.1.4 Grouping primitives 206

7.1.5 Collision detection 208

7.1.6 Adding signals and animations to primitives 209

7.2 Graphics scene class QGraphicsScene 211

7.2.1 Managing primitives 211

7.2.2 Embedding controls 212

7.3 Graphics view class QGraphicsView 214

7.3.1 The size relationship between view and scene 215

7.3.2 View transformation 216

7.4 Event delivery and coordinate transformation 217

7.4.1 Event Delivery Order 217

7.4.2 Coordinate transformation 219

7.5 Chapter Summary 221

Chapter 8 Packaging 222

8.1 PyInstaller 222

8.1.1 Environment configuration 222

8.1.2 Two Packing Modes 223

8.1.3 Debugging effect of black frame 225

8.1.4 Adding icons to executable files 226

8.1.5 Packaging resource files 226

8.1.6 Reduce the size of the packaged file 228

8.1.7 Other commonly used commands 230

8.1.8 Use PyInstaller to package programs developed with PyQt 232

8.2 Night 234

8.2.1 Environment configuration 234

8.2.2 Two Packing Modes 237

8.2.3 Adding icons to executable files 239

8.2.4 Packaging resource files 240

8.2.5 Enabling plugins 242

8.2.6 Reducing the size of the package file 243

8.2.7 Other commonly used commands 244

8.2.8 Using Nuitka to package programs developed with PyQt 246

8.3 Chapter Summary 247

Chapter 9 Developing Visual Crawling Software 248

9.1 Realize the crawler function 249

9.1.1 Analyzing the target website 249

9.1.2 Writing crawler code 250

9.2 Combining crawlers with interfaces 252

9.2.1 Complete interface layout 252

9.2.2 Writing crawler threads 254

9.2.3 Display crawling data and logs on the interface 257

9.2.4 Realize the save function 259

9.3 Sound effects and beautification 262

9.3.1 Adding sound effects 262

9.3.2 Beautify the interface 263

9.4 Packing 264

9.4.1 Package 264 with PyInstaller

9.4.2 Packaging 265 with Nuitka

9.5 Chapter Summary 266

Chapter 10 Developing the Classic Snake Game 267

10.1 Writing a game scene 268

10.1.1 Drawing the background and the snake icon 269

10.1.2 Drawing fractions 270

10.1.3 Drawing movable regions and borders 271

10.1.4 Drawing the "Pause" and "Continue" buttons 272

10.1.5 Draw game failure prompt 274

10.1.6 Displaying the scene in the view window 275

10.2 Adding food and eating snakes 277

10.2.1 Adding food to the scene 277

10.2.2 Adding a Snake to the Scene 279

10.2.3 How to make the snake move 283

10.3 Implementing the rest of the game logic 284

10.3.1 Use the arrow keys to control the snake 284

10.3.2 Restarting, pausing and continuing 286

10.3.3 Playing audio 287

10.4 Packaging 289

10.4.1 Packaging with PyInstaller 289

10.4.2 Packaging with Nuitka 290

10.5 Chapter Summary 291

Guess you like

Origin blog.csdn.net/La_vie_est_belle/article/details/129892586