Sliders: only update funtion on button_release_event

Hello everyone,

I was playing around with this /examples/widgets/ and thought about
how to use it in my case. I'd like to controll a parameter which - if
changed - starts a calculation which last about some seconds. So
dragging=False would be exactly what I'm looking for! But on the other hand
I'd like to see the slider moving and the value shown altering!

A look at the code in made me think about how to change the code to
achieve this. Here's my suggestion (my is also attached):

      update_func_only_on_release_event : The function specified by on_changed
          is normally updated on motion_notify_event if dragging is True.
          However if you don't want it to get updated (because it would take
          too long or whatever) but nevertheless want to see the slider moving
          then set dragging=True and update_func_only_on_release_event=True.
           (Therefore: dragging=False and
            update_func_only_on_release_event=False makes no sense and
            dragging=False makes update_func_only_on_release_event=True.)

def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt='%1.2f',
                 closedmin=True, closedmax=True, slidermin=None,
                 slidermax=None, dragging=True,
        ... snip ...
        if dragging:
            self.update_func_only_on_release_event = \
            self.update_func_only_on_release_event = False
        ... snip ...

        ax.figure.canvas.mpl_connect('button_press_event', self._update)
        if dragging:
            ax.figure.canvas.mpl_connect('motion_notify_event', self._update)
        # VVV new #
        if self.update_func_only_on_release_event:
            ax.figure.canvas.mpl_connect('button_release_event', self._update)
        # ^^^ new #
        ... snip ...

def set_val(self, val, name):
        self.poly.xy[-1] = val, 0
        self.poly.xy[-2] = val, 1
        if self.drawon:
        self.val = val
        if not self.eventson: return
        # VVV new #
        if not self.update_func_only_on_release_event or \
           (name == 'button_release_event' and
        # ^^^ new #
            for cid, func in self.observers.items():

To see what happens I altered the example/widgets/ to the one also

So far so good. But I'm not really convinced by this change (are you?). I'm
not sure if a list instead of dragging and update_func_only_on_release_event
would be better. Sliders could be initialized with two lists:
update_slider_on = ['button_press_event', 'motion_notify_event']
update_func_on = ['button_release_event']
The drawback here: A lot of all possible combinations are useless!

Please let me know what you're thinking about this.

Have a nice weekend
Martin (38.5 KB) (1.83 KB)