一、QMessageBox消息框有以下几种类型:
QMessageBox.information 信息框
QMessageBox.question 问答框
QMessageBox.warning 警告
QMessageBox.ctitical 危险
QMessageBox.about 关于
二、注意:一定要导入模块哟
from PyQt5.QtWidgets import QApplication,QMainWindow,QFileDialog,QMessageBox
三、举例(二次确认框)
def restartserver_168(self): A = QMessageBox.question(self,'确认','是否确定重启服务器?',QMessageBox.Yes | QMessageBox.No)#创建一个二次确认框 if A == QMessageBox.Yes: Restart = requests.get('http://192.168.34.168:5400/summitTest?cmd=restartGame') soup = BeautifulSoup(Restart.text,'html.parser') List_soup = list(soup) self.textEdit_2_168.append('168服务器重启成功'+' ')#打印当前时间到UI显示,提示完成重启 else: self.textEdit_2_168.append('已取消重启168服务器'+' ')#打印当前时间到UI显示,提示取消重启
动图演示:
上面只是常用的那个二次确认框,如果还有更多的需求,可以访问外部链接:
https://www.jianshu.com/p/264942d7383a
https://blog.csdn.net/Wang_Jiankun/article/details/83269859
https://www.cnblogs.com/kris-wang/p/12208213.html
https://blog.csdn.net/qq_41551450/article/details/104947551