Author jgoeders
Recipients jgoeders
Date 2013-08-08.16:55:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.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()

Here is the error stack:
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib64/python2.7/lib-tk/", line 1410, in __call__
    return self.func(*args)
  File "/home/jgoeders/workspace/tester/", line 19, in entry_focus_lost
    widget_with_focus = self.focus_get()
  File "/usr/lib64/python2.7/lib-tk/", line 446, in focus_get
    return self._nametowidget(name)
  File "/usr/lib64/python2.7/lib-tk/", line 1079, in nametowidget
    w = w.children[n]
KeyError: '#140030874747536'
Date User Action Args
2013-08-08 16:55:42jgoederssetrecipients: + jgoeders
2013-08-08 16:55:42jgoederssetmessageid: <>
2013-08-08 16:55:42jgoederslinkissue18686 messages
2013-08-08 16:55:41jgoederscreate