【Python】
Windows Python GUI
- PySide6对Python版本有要求,至少Python3.6,以64位Python3.8+为佳;
- 可用Qt Designer设计UI,通过pyside6-uic把UI文件转换成py文件,以便其它py文件引用
pyside6-uic.exe xxx.ui -o xxx.py
import sys
from PySide6.QtWidgets import QApplication, QWidget
from xxx import yyy # yyy是UI转成的py文件中的类名
- 使用pyinstaller打包成应用文件
# -F 单个文件,-w 无控制台窗口
pyinstaller -F -w -i xxx.ico xxx.py
- 屏蔽traceback
import sys
def custom_excepthook(exctype, value, traceback):print(f"Error: {value}", file=sys.stderr)if __name__ == "__main__":sys.excepthook = custom_excepthook