Eliminating AttributeError: 'tuple' object has no attribute 'focus_set' (Python 2.7) Eliminating AttributeError: 'tuple' object has no attribute 'focus_set' (Python 2.7) tkinter tkinter

Eliminating AttributeError: 'tuple' object has no attribute 'focus_set' (Python 2.7)


The body method is supposed to return the widget that should be given focus. This is why you get the error that you get: tkinter is trying to give focus to what is supposed to be a widget, but is instead a tuple. In your case, you probably want to return self.t1

To be able to get the value of the dialog, you need to define the method apply which should save the values to self.result. You can then query the result when the dialog is dismissed.

d = MyDialog(root)root.wait_window(d.top)print("the value is %s" % d.result)

A more complete example is here: http://effbot.org/tkinterbook/tkinter-dialog-windows.htm