Reputation: 268
So I'm doing a simple program that basically makes a scale/slidebar on the screen. When I run the application the scale shows up and works, but it doesn't print the values to the console(terminal). Instead it prints error messages
import Tkinter
class App:
def __init__(self,parent):
self.scale = Tkinter.Scale(parent,from_ = 0, to = 100, command = self.getVal)
self.scale.pack()
def getVal(self):
amount = self.scale.get()
print str(amount)
root = Tkinter.Tk()
app = App(root)
root.mainloop()
This is the error message:
Exception in Tkinter callback
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk/Tkinter.py", line 1403, in __call__
return self.func(*args)
TypeError: getVal() takes exactly 1 argument (2 given)
I'm pretty new at Tkinter so I'm a little lost.
EDIT: Python 2.5 guys. sorry.
Upvotes: 0
Views: 245
Reputation: 414129
The command
callback receives a new scale value as an argument. Change getVal
definition to:
def getVal(self, newscale):
print newscale
Upvotes: 2