I have a scale that calls a function to get the scale number. I want to have a lot of more things in that function, and I would like them to happen not only if I move the scale, but also If I select the checkbutton. The problem is the Scale sends a variable to the function (position of the scale) and the checkbutton doesn't, so If I use the command of the checkbutton to call the same function I receive an error. Anybody knows if is possible to call the same function with a Scale and a Checkbutton?
from tkinter import *
root = Tk()
def get_scale(scale_value):
print(scale_test.get())
scale_test = Scale(root, from_=0, to = 10, command = get_scale)
button_test = Checkbutton(root)
scale_test.pack()
button_test.pack()
root.mainloop()
Thank you @Mike67, it works:
from tkinter import *
root = Tk()
def get_scale(scale_value = 1):
print(scale_test.get())
scale_test = Scale(root, from_=0, to = 10, command = get_scale)
button_test = Checkbutton(root,command = get_scale)
scale_test.pack()
button_test.pack()
root.mainloop()