Python Tkinter Call A Dictionary With A Stringvar?
I'm working with tkinter in python and I have an annoying bug that I can't seem to fix, although the answer is probably obvious. I am trying to call a dictionary with a string, bu
Solution 1:
Just as you had to call set
method of StringVar
object, you also need to call get
to retrieve the str
data.
print weightsy[acadw.get()]
The dictionary doesn't know to convert your object into a string so it attempts to get the value associated with acadw
. You get a TypeError
rather than a KeyError
since StringVar
objects happen to be unhashable.
Post a Comment for "Python Tkinter Call A Dictionary With A Stringvar?"