PySide2 Publishing Program

1. Official release program

For the QT interface program we developed earlier, you only need to execute the following command on Windows to create an independent exe program.

1
pyinstaller httpclient.py --noconsole --hidden-import PySide2.QtXml

--noconsole Specify no command line window, otherwise when our program runs, there will be another black window.

--hidden-import PySide2.QtXml The parameter is because this QtXml library is dynamically imported, and PyInstaller cannot analyze it, we need to tell it.

Finally, don’t forget to copy the ui files needed by the program to the package directory.

2. Program icon

2.1 The icon of the program running window

1
2
3
4
5
from PySide2.QtGui import  QIcon

app = QApplication([])
# 加载 icon
app.setWindowIcon(QIcon('logo.png'))

2.2 The program file icon

It can be specified by the parameter --icon="logo.ico" when PyInstaller creates an executable program.

1
pyinstaller httpclient.py --noconsole --hidden-import PySide2.QtXml --icon="logo.ico"

If you only have png files, you can use the online png to ico file website to generate ico, such as the following two websites:

Site 1
Site 2


PySide2 Publishing Program
https://www.hardyhu.cn/2022/08/06/PySide2-Publishing-Program/
Author
John Doe
Posted on
August 6, 2022
Licensed under