Python PyQt5: How to show an error message with PyQt5

前端 未结 6 1311
别那么骄傲
别那么骄傲 2020-12-15 13:00

In normal Python (3.x) we always use showerror() from the tkinter module to display an error message but what should I do in PyQt5 to display exactly the same message type a

6条回答
  •  情书的邮戳
    2020-12-15 13:59

    All above options didn't work for me using Komodo Edit 11.0. Just had returned "1" or if not implemented "-1073741819".

    Usefull for me was: Vanloc's solution.

    def my_exception_hook(exctype, value, traceback):
        # Print the error and traceback
        print(exctype, value, traceback)
        # Call the normal Exception hook after
        sys._excepthook(exctype, value, traceback)
        sys.exit(1)
    
    # Back up the reference to the exceptionhook
    sys._excepthook = sys.excepthook
    
    # Set the exception hook to our wrapping function
    sys.excepthook = my_exception_hook
    

提交回复
热议问题