PyQt5 graphical interface development - packaged into executable file EXE

1 Introduction

As a module of Python, PyQt5 has more than 620 classes and 6000 functions and methods. This is a cross-platform toolkit, it can run on all major operating systems, including UNIX, Windows, Mac OS. pyqt5 is dual licensed. Developers can choose between GPL and commercial licenses.

PyQt5 essentially rewrites C++'s QT in python, so first understand the PyQt5 library structure:

QtCore: Covers core non-GUI functions, including processing time, files and directories, various data types, streams, URLs, MIME types, threads or processes, etc.
QtGui: Classes that cover a variety of basic graphics functions, including window system integration, event handling, 2D graphics, basic icons, fonts, and text.
QtWidgets: Contains a set of UI element controls for creating interfaces that conform to the system style.
QtMultimedia: Contains classes for handling multimedia content and APIs to access camera and radio functionality.
QtBluetooth: Contains classes for scanning for devices and connecting and interacting with them.
QtNetwork: Contains classes for network programming.
QtPositioning: Contains classes for determining position by using various possible sources including satellite, Wi-Fi or text files.
Enginio: Implements a client library for accessing the Qt Cloud Service hosted application runtime.
QtWebSockets: Contains classes that implement the WebSocket protocol.
QtWebEngine: Provides classes for integrating QML Web Engine objects with Python.
QtWebEngineCore: Contains the core Web Engine classes.
QtWebEngineWidgets: Contains the Chromium-based web browser.
QtXml: Contains classes for processing XML files
QtSvg: Provides classes for displaying SVG file content
QtSql: Provides classes for processing databases.
QtTest: Contains functions to enable unit testing of PyQt5 applications.

2 Packaged into an executable file EXE

We use pyInstaller to implement PyQt5 packaging, the packaging command format:

pyinstaller [选项] 文件名

options:

-F, --onefile is packaged into a single exe file, which is similar to the static compilation of C language into an executable program file. The advantage is that there is only one executable file, and the disadvantage is that the startup program is slow.

-D, --onedir Create a directory containing exe files and many dependent libraries (default option), similar to dynamically compiled executable programs in C language. The advantage is that the startup program is fast, and the disadvantage is that there are many files. This option is recommended.

-c, --console, --nowindowed use console, no interface (default)

-w, --windowed, --noconsole use window, no console

-i=xxx.ico, --icon=xxx.ico, specify the application icon

For example, package a program in the form of a dynamic library and specify an icon:

pyinstaller -D -w -i=logo.ico demo.py

Reference article: https://blog.csdn.net/kobepaul123/category_11618383.html

Guess you like

Origin blog.csdn.net/qq_40507857/article/details/126700960