I'm making a settings menu for my game, and would like to know if it is possible to play a sound every time a value of a scale is changed. For example, the user changes the scale from 1 to 2, a sound would play.
1 Answer
\$\begingroup\$
\$\endgroup\$
You are looking for callback function of tkinter Scale()
. Check API :
command: A procedure to be called every time the slider is moved. This procedure will be passed one argument, the new scale value. If the slider is moved rapidly, you may not get a callback for every possible position, but you'll certainly get a callback when it settles.
So you can do something like this:
def callback(value=None):
# play a sound here
s = Scale( *other parameters*... , command=callback)