首页 > 代码库 > pyqt 按钮调用例子学习

pyqt 按钮调用例子学习

UI文件及代码文件:http://yunpan.cn/QCktWsjsgRakf(提取码:d330)

如下图:

.PY文件代码如下:

from a import Ui_Form

from b import Ui_Form1

import sys

from PyQt4.QtGui import  *

from PyQt4.QtCore import *

from PyQt4.Qt import *

class Exr02(QDialog,Ui_Form):

    def __init__(self,parent=None):

        super(Exr02,self).__init__(parent)

        self.setupUi(self)

        self.textnr()

        self.pushButton.clicked.connect(self.dianyong)

    def dianyong(self):

        self.yn=Yn()

        self.yn.show()

    def textnr(self):

        self.addlabel.setText(‘hello python\n‘

                              ‘hello qt\n‘

                              ‘win7 64bit\n‘

                              ‘python2.7.8\n‘

                              ‘zh‘)

class Yn(QDialog,Ui_Form1):

    def __init__(self,parnet=None):

        super(Yn,self).__init__(parnet)

        self.setupUi(self)

        self.pushButton.clicked.connect(self.Yesclose)

        self.pushButton_2.clicked.connect(self.Noclose)

    def Yesclose(self):

        self.close()

    def Noclose(self):

        pass

app=QApplication([])

e=Exr02()

e.show()

sys.exit(app.exec_())

pyqt 按钮调用例子学习