Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e86271a

Browse files
committed
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).
1 parent 1f41f84 commit e86271a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ def _substitute(self, *args):
585585
e.keysym = K
586586
e.keysym_num = tk.getint(N)
587587
e.type = T
588-
e.widget = self._nametowidget(W)
588+
try:
589+
e.widget = self._nametowidget(W)
590+
except KeyError:
591+
e.widget = W
589592
e.x_root = tk.getint(X)
590593
e.y_root = tk.getint(Y)
591594
return (e,)

0 commit comments

Comments
 (0)