Friday, 1 June 2018

How can I add a "show details" button to a tkinter messagebox?

I have a Python script which uses tkinter.messagebox to display an error message with traceback details if an unexpected exception occurs.

import tkinter.messagebox as tm
import traceback

try:
    1/0
except Exception as error:
    message = "An error has occurred: '" + str(error) + "'."
    detail = traceback.format_exc()
    tm.showerror(title="Error", message=message, detail=detail)

Standard tkinter error

Displaying tracebacks with the -detail attribute has a few drawbacks.

Instead of displaying error details by default, I would like to add a "show details" button which would display more information in a read-only text field.

Detailed error for "division by zero"

How can I add a "show details" button to a tkinter messagebox?



from How can I add a "show details" button to a tkinter messagebox?

No comments:

Post a Comment