qt designer是python設計裡面乙個非常實用的工具,使得人們編寫qt介面可以不僅僅是使用純**,而可以在視覺化的基礎上設定,非常方便。
配置環境之前我們需要用到兩個東西:
designer(ui視覺化開發介面)--可以生成***.ui檔案
pyuic5(將 qt designer 生成的 ***.ui 檔案轉換成 python **)
需要配置designer與pyuic5
一. 配置designer
1.開啟設定面板,file-setting...
2.開啟新增外部工具面板,tools-external tools
3.新增工具面板,分別設定1(name,description),2(program,arguments,working directory)
program: designer.exe 的路徑
working directory: 設定儲存的 ui 檔案位置,$filedir$ 表示檔案所在目錄
4.designer的使用
二. 配置pyuic5(與上述新增designer類似)
1.開啟設定面板,file-setting...
2.開啟新增外部工具面板,tools-external tools
3.新增工具面板,分別設定1(name,description),2(program,arguments,working directory)
這裡arguments新增的是:$filename$ -o $filenamewithoutextension$.py
4.pyuic5的使用
新增後可以直接在工作列表中將ui檔案轉換成py檔案
如下圖操作:通過1,2,3步驟,直接在工作目錄下生成py檔案
mainwindow.py的部分**
在轉換後的檔案頭部新增**:
importcrtl + shift + f10執行sys尾部新增**:
if__name__ == '
__main__':
mainwindow =qmainwindow()
ui =ui_mainwindow()
ui.setupui(mainwindow)
mainwindow.show()
使用PyQT5 designer的相關問題
1.安裝 如果即沒有安裝過pyqt5也沒有安裝過其它相關設定工具,則直接安裝pyqt5 tools pip install pyqt5 tools i此時會先安裝pyqt5 tools,然後再自動安裝pyqt5。pyqt5 tools比較大,安裝時最好指定國內映象。2.啟動 進入cmd,直接輸入py...
PyQt5 designer 視覺化執行流程
將designer設計好的檔案儲存到指定資料夾,字尾為.ui。win r 輸入cmd,cd到1中的資料夾路徑中,輸入pyuic5 o name.py name.ui此時資料夾中的.ui檔案轉換為.py檔案。在1的資料夾中建立main.py,內容如下 import sys import mywindo...
pyqt5配置環境
file setting tools external tools中新增qtdesigner和pyuic。qtdesigner在pyqt5 tools包中,具體路徑為venv lib site packages pyqt5 tools qt bin designer.exe,工作目錄填 projec...