When I try assigning a dictionary item as a radiobutton variable after defining it as a type tk.Stringvar(), the get function returns PY_VAR0 rather than the string it was assigned.
###################################################
root = tk.Tk()
variables = dict()
variables['Language']=tk.StringVar()
def cb():
print(variables.get('Language'))
for Lang in ('English', 'German', 'French'):
tk.Radiobutton(root, text=Lang, variable=variables['Language'], value=Lang, command=cb).pack()
root.mainloop()
If I substitute the dictionary with a single variable the code works as expected.
##########################################################
root = tk.Tk()
Language=tk.StringVar()
def cb():
print(Language.get())
for Lang in ('English', 'German', 'French'):
tk.Radiobutton(root, text=Lang, variable=Language, value=Lang, command=cb).pack()
root.mainloop()
Found the problem, need to call out the dictionary key before the get() method is used.
i.e. variables['Language'].get()