pyqt4教程之messagebox使用示例分享
发布时间:2023-11-06 08:09:03
标签:pyqt4,messagebox
#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_()
0
投稿
猜你喜欢
- 本文实例讲述了Python设计模式之工厂方法模式。分享给大家供大家参考,具体如下:工厂方法模式(Factory Method Pattern
- 我在程序中加入了分数显示,三种特殊食物,将贪吃蛇的游戏逻辑写到了SnakeGame的类中,而不是在Snake类中。特殊食物:1.绿色:普通,
- 1. 用户必须在几秒钟知道网站是做什么的。注意力是因特网上最有价值的货币。 如果访问者无法在几秒钟之内得知你的网站的方向,他很有可能转而访问
- 代码如下#!/bin/python#coding=utf-8#python-version=2.75  
- 字符串的相似性比较应用场合很多,像拼写纠错、文本去重、上下文相似性等。评价字符串相似度最常见的办法就是:把一个字符串通过插入、删除或替换这样
- reindex更多的不是修改pandas对象的索引,而只是修改索引的顺序,如果修改的索引不存在就会使用默认的None代替此行。且不会修改原数
- 01. 应用场景及定义方式应用场景在实际开发中,对象 的 某些属性或方法 可能只希望 在对象的内部被使用,而 不希望在外部被访问到私有属性
- 其实golang用一个函数可以构建一个并发队列,现在编写一个灵活可控的队列程序先定义一个工作type Worker struct { &nb
- 在应用系统中,尤其在联机事务处理系统中,对数据查询及处理速度已成为衡量应用系统成败的标准。而采用索引来加快数据处理速度也成为广大数据库用户所
- 又从 James Padolsey 这里得到个好的点子。在实际写脚本过程中可能有段 Javascript 和 HTML 非常相关(比如实例化
- Postman生成okhttp代码依赖<dependency>  
- 常用时间转换及处理函数:import datetime# 获取当前时间d1 = datetime.datetime.now()print d
- 下面的例子简单的演示了DOM对XML的操作,详细解释请看代码中的注释 <? /****************************
- 在SQL Server中进行开发会让你身处险地,并且寻找快速解决方案。我们编辑了前十名关于SQL Server开发的常见问题。对常见的针对表
- 英国著名学者李约瑟早在100多年前就疑惑:为什么中国的科技在唐宋时代就已领先西方,却在明清时代落后下来。对此,人们一向认为这主要是儒家思想的
- 方法一: $(document).on('touchmove',function(e){ e.preventDefault(
- Python编程语言判断是否是目录在Python编程语言中可以使用os.path.isdir()函数判断某一路径是否为目录。其函数原型如下所
- 404错误是指在服务器找不到指定的页面。404错误页面是可以自定义的。Smashing Magazine为我们挑选了40个有创意的404错误
- mysql4.1以上版本连接时出现Client does not support authentic
- 数据采集XPath,XML路径语言的简称。XPath即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某