售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Dedication
About Packt
Why subscribe?
Packt.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Code in action
Conventions used
Get in touch
Reviews
Section 1: Deep Dive into PyQt
Getting Started with PyQt
Technical requirements
Installing Qt Designer
Introducing Qt and PyQt
PyQt5
Working with Qt and PyQt
Understanding Qt's documentation
Core Qt modules
Creating Hello Qt – our first window
Creating a PyQt application template
Introducing Qt Designer
Using Qt Designer
Summary
Questions
Further reading
Building Forms with QtWidgets
Technical requirements
Creating basic QtWidgets widgets
QWidget
QWidget as a top-level window
QLabel
QLineEdit
QPushButton and other buttons
QComboBox
QSpinBox
QDateTimeEdit
QTextEdit
Placing and arranging widgets
Layout classes
QHBoxLayout and QVBoxLayout
QGridLayout
QFormLayout
Controlling widget size
Container widgets
QTabWidget
QGroupBox
Validating widgets
Creating an IPv4 entry widget
Using QSpinBox for discrete values
Building a calendar application GUI
Building the GUI in code
Creating the widgets
Building the layout
Building the GUI in Qt Designer
First steps
Building the right panel
Building the event form
Previewing the form
Summary
Questions
Further reading
Handling Events with Signals and Slots
Technical requirements
Signal and slot basics
Restrictions on signal and slot connections
Creating custom signals and slots
Sharing data between windows using custom signals
Overloading signals and slots
Automating our calendar form
Using our hand-coded form
Creating and connecting our callback methods
The populate _list () method
The populate _form () method
The save _event () method
The delete _event () method
The check _delete _btn () method
Building our new category pop-up form
Using Qt Designer .ui files
Connecting slots in Qt Designer
Converting .ui files to Python
Automatic signal and slot connections
Using .ui files without conversion
Summary
Questions
Further reading
Building Applications with QMainWindow
Technical requirements
The QMainWindow class
Setting a central widget
Adding a status bar
Creating an application menu
Menus on macOS
Adding toolbars
Adding dock widgets
Other QMainWindow features
Standard dialog boxes
QMessageBox
QFileDialog
QFontDialog
Other dialog boxes
Saving settings with QSettings
Limitations of QSettings
Summary
Questions
Further reading
Creating Data Interfaces with Model-View Classes
Technical requirements
Understanding model-view design
Models and views in PyQt
Building a CSV editor
Creating a table model
Implementing read capabilities
Adding headers and sorting
Implementing write capabilities
Using the model in a view
Summary
Questions
Further reading
Styling Qt Applications
Technical requirements
Using fonts, images, and icons
Setting a font
Dealing with missing fonts
Adding images
Using icons
Using Qt resource files
Qt resource files and fonts
Configuring colors, style sheets, and styles
Customizing colors with palettes
Working with QBrush objects
Customizing the appearance with Qt Style Sheets (QSS)
The downside of QSS
Customizing the appearance with QStyle
Customizing Qt styles
Drawing widgets
Creating animations
Basic property animations
Animating colors
Using animation groups
Summary
Questions
Further reading
Section 2: Working with External Resources
Working with Audio-Visual Using QtMultimedia
Technical requirements
Simple audio playback
Recording and playing audio
The initial setup
Implementing sound playback
Loading the media
Tracking the playback position
Looping the audio
Setting the volume
Implementing recording
Examining and configuring the recorder
Recording and playing video
Building the basic GUI
Video playback
Video recording
Summary
Questions
Further reading
Networking with QtNetwork
Technical requirements
Low-level networking with sockets
Building a chat GUI
Building a UDP chat client
Connecting signals
Testing the chat
Building a TCP chat client
Working with data streams
Sending data over TCP
Connecting our backend and testing
HTTP communications with QNetworkAccessManager
Simple downloading
Posting data and files
Building the GUI
The POSTing backend
Testing the utility
Summary
Questions
Further reading
Exploring SQL with Qt SQL
Technical requirements
SQL basics
Creating tables
Inserting and updating data
Updating existing rows
Selecting data
Table joins
SQL subqueries
Learning more
Performing SQL queries with Qt
Building a form
Connecting and making simple queries
Getting information about the database
Making simple queries
Prepared queries
Using QSqlQueryModel
Finishing the GUI
Using model-view widgets without SQL
Delegates and data mapping
Data mapping
Filtering data
Using a custom delegate
Inserting custom rows in a table view
Summary
Questions
Further reading
Section 3: Unraveling Advanced Qt Implementations
Multithreading with QTimer and QThread
Technical requirements
Delayed actions with QTimer
Single shot timers
Repeating timers
Getting information from timers
Limitations of timers
Multithreading with QThread
The SlowSearcher file search engine
A non-threaded searcher
Testing our non-threaded search application
Adding threads
An alternate method
Threading tips and caveats
High concurrency with QThreadPool and QRunner
The file hasher GUI
A hash runner
Creating the thread pool
Testing the script
Threading and the Python GIL
Summary
Questions
Further reading
Creating Rich Text with QTextDocument
Technical requirements
Creating rich text using markup
HTML basics
Style sheet syntax
Semantic versus cosmetic tags
Structure and heading tags
Typography tags
Hyperlinks
Lists and tables
Fonts, colors, images, and styles
Document-wide styles
Images
Differences between Qt rich text and Web HTML
Manipulating rich text using QTextDocument
Creating the invoice application GUI
Building InvoiceView
The QTextDocument structure
Character formats
Adding basic content
Inserting a list
Inserting a table
Finishing and testing
Printing rich text
Updating the Invoice app for print support
Configuring the printer
Printing a page
Print previewing
Exporting to PDF
Summary
Questions
Further reading
Creating 2D Graphics with QPainter
Technical requirements
Image editing with QPainter
The meme generator GUI
The editing form
The main GUI
Drawing with QImage
The QPainter object
Saving our image
Custom widgets with QPainter
Building a GraphWidget
Painting the widget
Using GraphWidget
Animating 2D graphics with QGraphicsScene
First steps
Making a scene
Creating the tanks
Creating the bullets
Collision detection
Finishing the game
Summary
Questions
Further reading
Creating 3D Graphics with QtOpenGL
Technical requirements
The basics of OpenGL
The rendering pipeline and drawing basics
Programs and shaders
A simple vertex shader
A simple fragment shader
Embedding OpenGL drawings with QOpenGLWidget
First steps with OpenGLWidget
Creating a program
Accessing our variables
Configuring a projection matrix
Drawing our first shape
Creating a 3D object
Animating and controlling OpenGL drawings
Animating in OpenGL
Zooming in and out
Summary
Questions
Further reading
Embedding Data Plots with QtCharts
Technical requirements
Making a simple chart
Setting up the GUI
Building a disk usage chart
Displaying real-time data
Building a CPU usage chart
Updating the chart data
Panning and zooming around the chart
Styling Qt charts
Building the memory chart
Chart styling
Styling axes
Styling the legend
Summary
Questions
Further reading
PyQt Raspberry Pi
Technical requirements
Running PyQt5 on the Pi
Editing Python on the Pi
Running PyQt5 applications on the Pi
Controlling GPIO devices with PyQt
Connecting the LED circuit
Writing a driver library
PWM
Setting a color
Cleaning up
Creating the PyQt GUI
Controlling PyQt with GPIO devices
Connecting the sensor circuit
Creating the sensor interface
Displaying the readings
Adding a hardware button
Expanding the circuit
Implementing the button driver
Summary
Questions
Further reading
Web Browsing with QtWebEngine
Technical requirements
Building a basic browser with QWebEngineView
Using the QWebEngineView widget
Allowing multiple windows and tabs
Adding a tab for pop-up windows
Advanced QtWebEngine usage
Sharing a profile
Viewing history
Web settings
Building a text search feature
Summary
Questions
Further reading
Preparing Your Software for Distribution
Technical requirements
Structuring a project
Tic-tac-toe
The engine class
The board class
The main window class
Module-style structure
Structuring the module
Non-Python files
Documentation and metadata
The LICENSE file
The README file
The docs directory
The requirements.txt file
Other files
Distributing with setuptools
Writing the setuptools configuration
Basic metadata arguments
Packages and dependencies
Non-Python files
Executables
Source distributions
Creating a source distribution
Installing a source distribution
Built distributions
Types of built distributions
Creating a wheel distribution
Installing a built distribution
Compiling with PyInstaller
PyInstaller overview
Basic command-line usage
The .spec file
Preparing QTicTacToe for PyInstaller
Dealing with non-Python files
Further debugging
Summary
Questions
Further reading
Answers to Questions
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Upgrading Raspbian 9 to Raspbian 10
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜