Best practice approach for trapping Tkinter exceptions

python at python at
Sat Nov 6 12:04:56 CET 2010

What is the best practice approach for trapping Tkinter

Example: When using the Text widget with undo=True, attempting an
edit_undo or edit_redo raises a Tkinter exception when there are
no actions to undo or redo.

It doesn't look like there's a Tkinter specific exception being
raised - only a general exception.

Is there a better way to trap Tkinter exceptions than wrapping
certain Tkinter commands like the following:

except Exception as e:

If I print the exception that I trapped, all I get is the name of
the Tkinter method I tried to execute, eg. edit_undo.

For bonus points: Is there a way to query a Tkinter Text widget
to determine if there are undo or redo actions available to

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list