PyQt4调用UI文件
方法1,转换到py调用
指令
pyuic4 test.ui -o testUi.py
方法2.直接调用ui文件
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: test
Description :
Author : 神秘藏宝室
date: 2017-09-27
-------------------------------------------------
Change Activity:
2017-09-27:
-------------------------------------------------
"""
import sys
from PyQt4 import QtCore, QtGui, uic
qtCreatorFile = "test.ui" # Enter file here.
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
class MyApp(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.pushButton.clicked.connect(self.lableDisplay)
def lableDisplay(self):
self.label.setText(u"确认")
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MyApp()
window.show()
sys.exit(app.exec_())
文章对您有帮助,开心可以打赏我,金额随意,欢迎来赏!
需要电子方面开发板/传感器/模块等硬件可以到我的淘宝店逛逛