一、ui界面制作
1.安裝pyside6
終端中使用如下命令安裝pyside6
pip install pyside6
2.使用Qt Designer制作ui界面
在python安裝目錄下使用designer制作ui界面,
另存為.ui文件
3.界面轉(zhuǎn)換(.ui文件 --> .py文件)
終端中使用如下命令進行界面轉(zhuǎn)換,將ui文件轉(zhuǎn)換為py文件才能使用pyside6-uic xxx.ui -o xxx.py
4.python代碼中使用ui界面
方式1:
from PySide6.QtWidgets import QApplication, QWidget, QListWidget, QVBoxLayout
# 從Checkin.py(轉(zhuǎn)換后的ui界面文件)中導入對應的類
from Checkin import Ui_Form
# 這里MyWindow繼承的類要與所制作的界面的類型一致(如制作時選擇QMainWindow則這里也要繼承QMainWindow)
class MyWindow(QWidget):
def __init__(self):
super().__init__()
# 使用ui界面
self.ui = Ui_Form()
self.ui.setupUi(self)
if __name__ == '__main__':
app = QApplication([])
window = MyWindow()
window.show()
app.exec()
方式2:
from PySide6.QtWidgets import QApplication, QWidget, QListWidget, QVBoxLayout
from Checkin import Ui_Form
# 多繼承,繼承setupUi方法,然后直接調(diào)用setupUi方法
class MyWindow(QWidget, Ui_Form):
def __init__(self):
super().__init__()
self.setupUi(self)
if __name__ == '__main__':
app = QApplication([])
window = MyWindow()
window.show()
app.exec()
?
二、為各控件綁定交互邏輯
為各個控件寫具體的交互邏輯
?
三、打包可執(zhí)行程序
1.安裝pyinstaller
pip install pyinstaller
可能出現(xiàn)連接超時安裝不上的情況,可以切換源進行下載
文章來源:http://www.zghlxwxcb.cn/news/detail-722960.html
pip install -i http://pypi.douban.com/simple/ pyinstaller
2.打包程序
#打包成多個文件
pyinstaller -D xxxxx.py
#打包成多個文件,且隱藏命令行窗口
pyinstaller -D xxxxx.py
#打包成單個文件
pyinstaller -F xxxxx.py
#打包成單個文件,且隱藏命令行窗口
pyinstaller -F xxxxx.py
執(zhí)行完成后在目錄下會出現(xiàn)以下3種文件:
build 文件夾是存放打包時臨時文件用的(沒用)
dist 文件夾存放了打包好的應用(其中的exe文件就是可執(zhí)行程序)
xxxxx.spec 內(nèi)容是 PyInstaller 根據(jù)我們的命令行生成的打包參數(shù)文章來源地址http://www.zghlxwxcb.cn/news/detail-722960.html
到了這里,關于【爬蟲】python打包可執(zhí)行程序(ui界面制作完成后)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!