【问题标题】:Unexpected type 'StandardButton' PyQt5 messagebox意外类型“标准按钮”PyQt5 消息框
【发布时间】:2020-06-22 03:08:01
【问题描述】:

我正在尝试只弹出一个消息框,并且只有点击“确定”的选项。

这是代码:

show_message_box(QMessageBox.Critical,
                 "ERREUR",
                 "Il n'est pas possible de bloquer cette plage horraire pour " + employee, QMessageBox.Ok)

我遇到了错误setInformativeText(Self,str): argument 1 has unexpected type 'StandardButton'

我的其他 msgbox 工作正常,但它们有 yesno 选项。这个,我只想要ok选项。

感谢您的帮助

【问题讨论】:

标签: python pyqt5


【解决方案1】:

试试看:

import sys
from PyQt5.Qt import *


class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.error_popup()

    def error_popup(self):
        
        employee = 'Name 1'
        
        QMessageBox.critical(
            self,
            "ERREUR",
            f"Il n'est pas possible de bloquer cette plage horraire pour <b>{employee}</b>", 
            QMessageBox.Ok
        )
                 
        
if __name__ == "__main__":
    App = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(App.exec_())        

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多