When setting the event structure fields, don't die when the widget
name is not registered; simply use the string. This happens for
tear-off widgets (e.g. if you've registered enter/leave events for the
menu).
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 7ac6a0f..bc7dae7 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -585,7 +585,10 @@
e.keysym = K
e.keysym_num = tk.getint(N)
e.type = T
- e.widget = self._nametowidget(W)
+ try:
+ e.widget = self._nametowidget(W)
+ except KeyError:
+ e.widget = W
e.x_root = tk.getint(X)
e.y_root = tk.getint(Y)
return (e,)