Python Forum

Full Version: Takes 1 Positional Argument but 2 were Given
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is the code I have.

self.contrast = Scale(root, command=self.editingImage, from_= -100, to = 100, orient = HORIZONTAL)

I am trying to call the function editingImage(self) whenever the scale is moved, but python keeps giving me the error:

TypeError: editingImage() takes 1 positional argument but 2 were given

Why is this? I am only putting in one argument, self. At least I think I am?
Try this and you'll see, that the command is called with one argument. The current Value.
import tkinter
root = tkinter.Tk()
tkinter.Scale(root, command=print, from_=0, to=200, orient=tkinter.HORIZONTAL).pack()
tkinter.Button(root, text='Close', command=root.destroy).pack()
root.mainloop()
Maybe you have forgotten to add the argument into your method. When there is only editingImage(self):, it's wrong.
The callback command is called with one argument.
Use instead editingImage(self, value): and do something with value in your editingImage method.
That worked! Thank you so much.