Tkinter, Python - Changing slider value without triggering callback Tkinter, Python - Changing slider value without triggering callback tkinter tkinter

Tkinter, Python - Changing slider value without triggering callback


I was faced with the same issue and neither inhibiting the callback nor setting a global variable to check the callback status worked for me, for some obscure reason the callback kept being called after my code had finished running.

Despite this the solution that worked for me is simple : I used a variable in the widget and set the value using the set method of the variable rather than the one of the widget.

value = DoubleVar()scale = Scale(master, variable=value, command=callback)scale.pack()scale.set(0) #<- this triggers the callback, no matter what I tried to stop itvalue.set(0) #<- this works like the previous line but without any callback


you could try something like this:

def program_move():    inhibit_callback = True    slider.value = #your value heredef callback(event, *args):    If inhibit_callback:        inhibit_callback = False        return    else:        #whatever you were going to do

and i think this should allow the callback to work normally when its a user triggered callback, but when the program triggers it it should break immediately after the callback is triggered and resets its own flag.