pyqt demo

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

"""
Module implementing MyDialog.
"""

from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import QDialog

from PyQt4.QtGui import QApplication
from PyQt4.QtGui import QMessageBox
from PyQt4 import QtCore

from Ui_maindlg import Ui_Dialog

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s
        
class MyDialog(QDialog, Ui_Dialog):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
    
    @pyqtSignature("")
    def on_pushButton_clicked(self):
        """
        Slot documentation goes here.
        """
        self.label.setText("xxx")
        self.pushButton.setText('ok')
        
        # TODO: not implemented yet
        #raise NotImplementedError
    
    @pyqtSignature("")
    def on_pushButton_exit_clicked(self):
        """
        Slot documentation goes here.
        """
        QMessageBox.information(self, _fromUtf8("system标题"), _fromUtf8("warning消息"), QMessageBox.Yes)
        QMessageBox.information(self,"english","test",QMessageBox.Yes)
        
        Dialog.close()
        # TODO: not implemented yet
        #raise NotImplementedError

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    Dialog = MyDialog()
    Dialog.show()
    sys.exit(app.exec_())
    

你可能感兴趣的:(pyqt demo)