接上次。
關於錯誤的處理。
pycharm ui 轉換為ui 報 Error: one input ui-file must be specified
上次是因為紅字部分大意了。初學。哈哈。
中間的內容;
-m PyQt5。uic。pyuic $FileName$ -o $FileNameWithoutExtension$。py
其實是一個命令列。
最後一行。也可以填寫
$FileDir$
我測試的沒問題。不知有沒有其他情況。
點選
生成同名。py,指成功了。但執行時沒顯示視窗。接著學習吧。
以上網上找的答案如下
修改pycharm 配置
入口:file——>setting——>tools——>Extenal Tools
Programs:D:\python\python。exe 【安裝目錄】
Parameters:-m PyQt5。uic。pyuic $FileName$ -o $FileNameWithoutExtension$。py 【固定格式】
Working directory:【專案目錄】
構建第一個介面
儲存在專案下。
生成py檔案。
修正一下。
新建一個main。py。。。
檢視程式碼:
# -*- coding: utf-8 -*-# Form implementation generated from reading ui file ‘main_win。ui’## Created by: PyQt5 UI code generator 5。15。0## WARNING: Any manual changes made to this file will be lost when pyuic5 is# run again。 Do not edit this file unless you know what you are doing。from PyQt5 import QtCore, QtGui, QtWidgetsclass Ui_main(object): def setupUi(self, main): main。setObjectName(“main”) main。resize(372, 113) self。openlabel = QtWidgets。QLabel(main) self。openlabel。setGeometry(QtCore。QRect(10, 20, 54, 16)) self。openlabel。setObjectName(“openlabel”) self。openline = QtWidgets。QLineEdit(main) self。openline。setGeometry(QtCore。QRect(70, 20, 251, 20)) self。openline。setObjectName(“openline”) self。openbutton = QtWidgets。QPushButton(main) self。openbutton。setGeometry(QtCore。QRect(330, 20, 31, 23)) self。openbutton。setObjectName(“openbutton”) self。pdf2picButton = QtWidgets。QPushButton(main) self。pdf2picButton。setGeometry(QtCore。QRect(90, 60, 75, 23)) self。pdf2picButton。setObjectName(“pdf2picButton”) self。pic2wmvButton = QtWidgets。QPushButton(main) self。pic2wmvButton。setGeometry(QtCore。QRect(210, 60, 75, 23)) self。pic2wmvButton。setObjectName(“pic2wmvButton”) self。retranslateUi(main) QtCore。QMetaObject。connectSlotsByName(main) def retranslateUi(self, main): _translate = QtCore。QCoreApplication。translate main。setWindowTitle(_translate(“main”, “Dialog”)) self。openlabel。setText(_translate(“main”, “開啟檔案”)) self。openbutton。setText(_translate(“main”, “。。。”)) self。pdf2picButton。setText(_translate(“main”, “pdf2pic”)) self。pic2wmvButton。setText(_translate(“main”, “pic2wmv”))
編輯程式碼(main。py):
from PyQt5。QtWidgets import *from main_win import Ui_mainif __name__ == ‘__main__’: import sys app=QApplication(sys。argv) main=QDialog() main_win=Ui_main() main_win。setupUi(main) main。show() sys。exit(app。exec_())
執行效果。
未完待續。。