当前位置: 移动技术网 > IT编程>脚本编程>Python > pyqt4教程之messagebox使用示例分享

pyqt4教程之messagebox使用示例分享

2019年04月01日  | 移动技术网IT编程  | 我要评论

kimiko老师,2014年春晚小品大全,教育心理学形成性考核册答案

复制代码 代码如下:

#coding=utf-8
#对话框
import sys
from pyqt4 import qtgui, qtcore
class window( qtgui.qwidget ):
    def __init__( self ):
        super( window, self ).__init__()
        self.setwindowtitle( "hello" )
        self.resize( 500, 500 )

        gridlayout = qtgui.qgridlayout()

        self.aboutbutton = qtgui.qpushbutton( "about" )
        gridlayout.addwidget( self.aboutbutton, 0, 0 )
        self.aboutqtbutton = qtgui.qpushbutton( "aboutqt" )
        gridlayout.addwidget( self.aboutqtbutton, 0, 1 )
        self.criticalbutton = qtgui.qpushbutton( "criticalbutton" )
        gridlayout.addwidget( self.criticalbutton, 1, 0 )
        self.infobutton = qtgui.qpushbutton( "info" )
        gridlayout.addwidget( self.infobutton, 1, 1 )
        self.questionbutton = qtgui.qpushbutton( "question" )
        gridlayout.addwidget( self.questionbutton, 2, 0 )
        self.warningbutton = qtgui.qpushbutton( "warning" )
        gridlayout.addwidget( self.warningbutton, 2, 1 )

        spacer = qtgui.qspaceritem( 200, 80 )
        gridlayout.additem( spacer, 3, 1, 1, 5 )
        self.setlayout( gridlayout )

        self.connect( self.aboutbutton, qtcore.signal( 'clicked()' ), self.onaboutbutton )
        self.connect( self.aboutqtbutton, qtcore.signal( 'clicked()' ), self.onaboutqtbutton )
        self.connect( self.criticalbutton, qtcore.signal( 'clicked()' ), self.oncriticalbutton )
        self.connect( self.infobutton, qtcore.signal( 'clicked()' ), self.oninfobutton )
        self.connect( self.questionbutton, qtcore.signal( 'clicked()' ), self.onquestionbutton )
        self.connect( self.warningbutton, qtcore.signal( 'clicked()' ), self.onwarningbutton )

    def onaboutbutton( self ):
        qtgui.qmessagebox.about( self, 'pyqt', "about" )

    def onaboutqtbutton( self ):
        qtgui.qmessagebox.aboutqt( self, "pyqt" )

    def oncriticalbutton( self ):
        r = qtgui.qmessagebox.critical( self, "pyqt", "criticalbutton", qtgui.qmessagebox.abort,
                                   qtgui.qmessagebox.retry, qtgui.qmessagebox.ignore )
        if r == qtgui.qmessagebox.abort:
            self.setwindowtitle( "abort" )
        elif r == qtgui.qmessagebox.retry:
            self.setwindowtitle( "retry" )
        elif r == qtgui.qmessagebox.ignore:
            self.setwindowtitle( "ignore" )
        else:
            pass

    def oninfobutton( self ):
        qtgui.qmessagebox.information( self, "pyqt", "information" )

    def onquestionbutton( self ):
        r = qtgui.qmessagebox.question( self, "pyqt", "question", qtgui.qmessagebox.yes, qtgui.qmessagebox.no, qtgui.qmessagebox.cancel )

    def onwarningbutton( self ):
        r = qtgui.qmessagebox.warning( self, "pyqt", "warning", qtgui.qmessagebox.yes, qtgui.qmessagebox.no )

        
app = qtgui.qapplication( sys.argv )
win = window()
win.show()
app.exec_()

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网