I am trying to create a GUI using Python 3.2.3 and the tkinter
module. I need an "array" of Scale
widgets but cannot for the life of me figure out how to return the values except by creating the Scale
widgets one at a time and having a separate function for each one called by its command
keyword argument passing the var
.
I can loop the widget creation bit and increment the row and column parameters as necessary but can't figure out how to retrieve the values of the Scale
widgets.
In "Basic" each widget would have an index which could be used to address it but I cannot find how anything similar is implemented in Python. Even worse - just with a single Scale
widget, I used:
from Tkinter import *
master = Tk()
w = Scale(master, from_=0, to=100)
w.pack()
w = Scale(master, from_=0, to=200, orient=HORIZONTAL)
w.pack()
mainloop()
#To query the widget, call the get method:
w = Scale(master, from_=0, to=100)
w.pack()
print w.get()
And got the response:
AttributeError: 'NoneType' object has no attribute 'get'
I am assuming this is some kind of version issue.
Are you sure you are using Python 3? Your example is Python 2. This simple example works with 1 widget:
With an array of widgets, you put them in a list
I hope that's what you want.
JPG