python3 + PyQt4 窗口示例

关键词:python3 + PyQt4 ,例子

# -*- coding: utf-8 -*-
"""
 update on 2018/2/28
 @Author  : su.su
"""
# Created by: PyQt4 UI code generator 4.11.4

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8

    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName(_fromUtf8("Dialog"))
        Dialog.resize(420, 100)
        self.label_3 = QtGui.QLabel(Dialog)
        self.label_3.setGeometry(QtCore.QRect(8, 30, 36, 21))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.textEdit = QtGui.QTextEdit(Dialog)
        self.textEdit.setGeometry(QtCore.QRect(50, 30, 251, 41))
        self.textEdit.setObjectName(_fromUtf8("textEdit"))
        self.pushButton_4 = QtGui.QPushButton(Dialog)
        self.pushButton_4.setGeometry(QtCore.QRect(320, 50, 75, 23))
        self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
        self.pushButton_4.clicked.connect(self.add_recode)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
        self.label_3.setText(_translate("Dialog", "搜索:", None))
        self.pushButton_4.setText(_translate("Dialog", "新增", None))

    def add_recode(self):
        self.textEdit.setText("")
        self.textEdit.append(u"Hello world ! ")


if __name__ == "__main__":
    import sys

    app = QtGui.QApplication(sys.argv)
    Dialog = QtGui.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
posted @ 2018-02-28 17:56  mthk  阅读(885)  评论(0编辑  收藏  举报