__author__ = 'Administrator'

import sys
from  PyQt4 import QtGui

class MessageBox(QtGui.QWidget):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.setGeometry(300,300,250,150)
        self.setWindowTitle('messagebox')
    def closeEvent(self, event):
        reply=QtGui.QMessageBox.question(self,'Message',
                                         'Are you sure to quit?',QtGui.QMessageBox.Yes,
                                         QtGui.QMessageBox.No)
        if reply==QtGui.QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()

app=QtGui.QApplication(sys.argv)
qb=MessageBox()
qb.show()
sys.exit(app.exec_())

 

相关文章:

  • 2022-12-23
  • 2021-06-08
  • 2021-11-19
  • 2022-01-25
  • 2022-01-09
  • 2021-11-09
  • 2021-07-22
  • 2021-10-09
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-08-15
  • 2022-12-23
相关资源
相似解决方案