If I run the following code from a terminal, I get a helpful error message in the terminal:
import Tkinter as tk
master = tk.Tk()
def callback():
raise
First a followup: Just today, a patch on the CPython tracker for the tkinter.Tk.report_callback_exception docstring made it clear that Jochen's solution is intended. The patch also (and primarily) stopped tk from crashing on callback exceptions when run under pythonw on Windows.
Second: here is a bare-bones beginning of a solution to making stderr function with no console (this should really be a separate SO question).
import sys, tkinter
root = tkinter.Tk()
class Stderr(tkinter.Toplevel):
def __init__(self):
self.txt = tkinter.Text(root)
self.txt.pack()
def write(self, s):
self.txt.insert('insert', s)
sys.stderr = Stderr()
1/0 # traceback appears in window
More is needed to keep the popup window hidden until needed and then make it visible.