QMessageBox消息框有以下几种类型:

  QMessageBox.information 信息框
  QMessageBox.question 问答框
  QMessageBox.warning 警告
  QMessageBox.ctitical危险
  QMessageBox.about 关于

一个简单的小例子:

pyqt5消息框QMessageBox

代码如下:(点击按钮调出消息框

    from PyQt5 import QtWidgets  
    from PyQt5.QtWidgets import QMessageBox  
        
    class MyWindow(QtWidgets.QWidget):  
        def __init__(self):  
            super().__init__()  
            self.myButton = QtWidgets.QPushButton(self)  
 
            self.myButton.clicked.connect(self.msg)  
      
        def msg(self):  
            reply = QMessageBox.information(self,                         #使用infomation信息框  
                                        "标题",  
                                        "消息",  
                                        QMessageBox.Yes | QMessageBox.No)  
      
    if __name__=="__main__":    
        import sys    
        
        app=QtWidgets.QApplication(sys.argv)    
        myshow=MyWindow()  
        myshow.show()  
        sys.exit(app.exec_())    

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2021-11-01
  • 2022-02-12
  • 2021-05-25
猜你喜欢
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案