Message194693
I am experiencing a crash when calling focus_get() when a Tk Menu has focus. Here is sample code, just click the menu and it will crash.
import Tkinter as tk
class App(tk.Tk):
def __init__(self, *args, **kw):
tk.Tk.__init__(self, *args, **kw)
self.entry = tk.Entry(self)
self.entry.grid(padx=20, pady=20)
self.entry.focus_set()
self.entry.bind("<FocusOut>", self.entry_focus_lost)
self.menubar = tk.Menu(self)
self["menu"] = self.menubar
self.menufile = tk.Menu(self.menubar, tearoff=False)
self.menubar.add_cascade(menu=self.menufile, label="File")
def entry_focus_lost(self, event):
widget_with_focus = self.focus_get()
app = App()
app.mainloop()
Here is the error stack:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
return self.func(*args)
File "/home/jgoeders/workspace/tester/test_menu_focus.py", line 19, in entry_focus_lost
widget_with_focus = self.focus_get()
File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 446, in focus_get
return self._nametowidget(name)
File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1079, in nametowidget
w = w.children[n]
KeyError: '#140030874747536' |
|
Date |
User |
Action |
Args |
2013-08-08 16:55:42 | jgoeders | set | recipients:
+ jgoeders |
2013-08-08 16:55:42 | jgoeders | set | messageid: <1375980942.46.0.944431245569.issue18686@psf.upfronthosting.co.za> |
2013-08-08 16:55:42 | jgoeders | link | issue18686 messages |
2013-08-08 16:55:41 | jgoeders | create | |
|