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_())
posted on 2017-09-27 23:19  神秘藏宝室  阅读(867)  评论(0编辑  收藏  举报

 >>>转载请注明出处<<<