I have a function that is supposed to build a window according to which option in a dropdown menu is selected:
def buildview():
value = StringVar()
options = ["one", "two", "three"]
menu = OptionMenu(*(root, value) + tuple(options))
### Some window building accoring to the value selected... ###
value.trace_variable("w", buildview)
The exception that is raised looks like this (EDIT: Entire Traceback):
Traceback (most recent call last):
File "D:\Dropbox\PRO\infograbber\Infograbber 0.1.py", line 102, in <module>
mainloop()
File "C:\Python35\Python3564\lib\tkinter\__init__.py", line 405, in mainloop
_default_root.tk.mainloop(n)
File "C:\Python35\Python3564\lib\tkinter\__init__.py", line 1553, in __call__
self.widget._report_exception()
AttributeError: 'StringVar' object has no attribute '_report_exception'
What exactly is causing this? Can I not have a method call back itself like this? I don't even know where to start fixing this problem, so I'd appreciate any help.
I'm using Python 3.5 64 bit, Sublime Text 2, Windows 10.
EDIT: Added a test callback function:
def test(*args):
print("test")
and changed the above trace to
value.trace_variable("w", test)
Now the exception changed to this:
Traceback (most recent call last):
File "C:\Python35\Python3564\lib\tkinter\__init__.py", line 1549, in __call__
return self.func(*args)
File "D:\Dropbox\PRO\infograbber\Infograbber 0.1.py", line 56, in buildview
root.trace_variable("w", self.printcurrentarticle)
File "C:\Python35\Python3564\lib\tkinter\__init__.py", line 1948, in __getattr__
return getattr(self.tk, attr)
AttributeError: '_tkinter.tkapp' object has no attribute 'trace_variable'