abbrlink: da8afc03
title: 在Pychram中配置PyUIC5时文件路径说明与设置
related_posts: true
comments: true
copyright: true
top:
date: 2020-04-23 11:10:42
updated:
type:
tags:
- Python
- PyQt5
-
PyUIC5
categories: Python
password:近期需要使用PyQT5开发GUI界面,用到了QtDesigner生成.ui文件,但是在配置PyUIC时遇到了问题,找了十几个教程都没有说清楚,以下自身经历,写下总结。
基本配置说明
Program的设置是python目录下的Script下的pyuic5.exe
参数设定为:FileName -o FileNameWithoutExtension.py
文件路径设定
将当前.ui文件生成.py到当前目录
设定:FileDir
效果如下:
生成的代码如下:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'window.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(917, 546)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(100, 60, 93, 28))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 917, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "阿牛点击它"))
将当前.ui文件生成.py到项目主目录
路径: $ProjectFileDir $
这时你会发现生成的文件跑到了项目主目录下:
同时警告:
同时文件错误,没有py代码:
Comments NOTHING