pyqt5消息框QMessageBox


QMessageBox消息框有以下幾種類型:

  QMessageBox.information 信息框
  QMessageBox.question 問答框
  QMessageBox.warning 警告
  QMessageBox.ctitical危險
  QMessageBox.about 關於

一個簡單的小例子:

代碼如下:(點擊按鈕調出消息框

    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_())    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM