标签: pyuic

使用 pyuic 与 uic.loadUi 的优点

我目前正在使用 python 和 Qt,这对来自 C++ 版本的我来说是新的,我意识到在官方文档中它说 UI 文件可以从 python 类加载.ui或创建 python 类并将文件转换为.py文件。

我得到了使用它的好处,.ui它是动态加载的,因此不需要每次更改时都将其转换为 python 文件,但是这样做有什么好处?,运行时有任何改进吗?难道是别的什么?

谢谢

qt pyqt qt-designer pyuic pyside2

3
推荐指数
1
解决办法
1587
查看次数

如何从 pyuic .py 文件重建 .ui 文件

不久前,我使用 PyQt 做了一个项目。我创建了一些 .ui 文件并使用 pyuic4 生成了相应的 .py 文件。我想重新开始工作,但我丢失了 .ui 文件(我格式化了我的电脑并进行了备份,但 .ui 文件驻留在 Qt 设计器文件夹中并丢失了)。

有什么办法可以从生成的 .py 文件中恢复那些 .ui 文件?

python pyqt qt-designer pyuic

2
推荐指数
1
解决办法
3359
查看次数

通过导入PyQt5 Ui向按钮添加功能

我有一个名为guiNext.py和next.py的PyQt5 Ui,正在刷新用户界面。如何向UI按钮添加功能?这就是我所拥有的,当我运行next.py并单击HELLO按钮时,什么也没有发生。

guiNext.py:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'guiNext_001.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_nextGui(object):
    def setupUi(self, nextGui):
        nextGui.setObjectName("nextGui")
        nextGui.resize(201, 111)
        nextGui.setMinimumSize(QtCore.QSize(201, 111))
        nextGui.setMaximumSize(QtCore.QSize(201, 111))
        self.centralwidget = QtWidgets.QWidget(nextGui)
        self.centralwidget.setObjectName("centralwidget")
        self.helloBtn = QtWidgets.QPushButton(self.centralwidget)
        self.helloBtn.setGeometry(QtCore.QRect(10, 10, 181, 91))
        self.helloBtn.setObjectName("helloBtn")
        nextGui.setCentralWidget(self.centralwidget)

        self.retranslateUi(nextGui)
        QtCore.QMetaObject.connectSlotsByName(nextGui)

    def retranslateUi(self, nextGui):
        _translate = QtCore.QCoreApplication.translate
        nextGui.setWindowTitle(_translate("nextGui", "MainWindow"))
        self.helloBtn.setText(_translate("nextGui", …
Run Code Online (Sandbox Code Playgroud)

python pyqt qt-designer pyqt5 pyuic

2
推荐指数
1
解决办法
1559
查看次数

PyQt5:对象没有属性“exec_”,有两个主窗口

我是 PyQt 的新手,所以当我创建 UI 文件时,我只是复制了一个 Mainwindow (mainfile.ui) 并将其更改为生成另一个 UI 文件 (Intro.ui)。我知道这不是创建 UI 文件的好方法,因为它总是给出错误:object has no attribute 'exec_'.

这是代码:

MainFile = "mainfile.ui"

Ui_MainWindow, QtBaseClass = uic.loadUiType(MainFile)

FileIntro = "Intro.ui" 

Ui_WindowIntro,_ = uic.loadUiType(FileIntro)

class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):

    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)
        self.ButtonIntro.clicked.connect(self.OpenWindowIntro)
    def OpenWindowIntro(self):
        s = WindowIntro()
        s.show()
        s.exec_() #here is the problem.

class WindowIntro(QtWidgets.QMainWindow, Ui_WindowIntro):

    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_WindowIntro.__init__(self)
        self.setupUi(self)
        #close the window
        self.Button2.clicked.connect(self.Close)

    def Close(self):
        self.close()

if __name__ == "__main__":

    app = 0 # if not the core …
Run Code Online (Sandbox Code Playgroud)

python pyqt exec qt-designer pyuic

1
推荐指数
1
解决办法
6290
查看次数

标签 统计

pyqt ×4

pyuic ×4

qt-designer ×4

python ×3

exec ×1

pyqt5 ×1

pyside2 ×1

qt ×1