I have multiple similar Sliders, and want to call the function update with a certain argument when a the corresponding slider is changed. Passing additional parameters should work similarly to other widgets, e.g., on_clicked() of Button.
Simplified example using base code from Slider demo:
def update(val, string):
line.set_ydata(f(t, amp_slider.val, freq_slider.val))
print(string)
fig.canvas.draw_idle()
freq_slider.on_changed(update("Frequency updated"))
amp_slider.on_changed(update("Amplitude updated"))
The following doesn't pass the updated val at all, and hence obviously doesn't work. According to the documentation on_changed only accepts a callable function as a parameter. Is there a way to solve this without somehow incorporating mpl_connect, e.g. using a lambda function?