Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Set slider to min/max constraint when value exceeds constraint. #770

Merged
merged 1 commit into from

2 participants

@tonysyu

Currently, when a slider's limits are constrained by another slider (using slidermin/slidermax), the slider will simply return unchanged when you move the slider beyond the limits.

Instead, the slider should update to the min/max value when closedmin/closedmax attributes are True. This would match the behavior of the valmin/valmax limits.

@tonysyu tonysyu Set slider to min/max constraint when value exceeds constraint.
Currently, when a slider's limits are constrained by another slider (using `slidermin/slidermax`), the slider will simply return unchanged when you move the slider beyond the limits.

Instead, the slider should update to the min/max value when `closedmin/closedmax` attributes are True. This would match the behavior of the `valmin/valmax` limits.
b61507b
@WeatherGod
Collaborator

This change looks ok to me. Sorry for the delay. Tony, I take it that you haven't encountered any issues with this change?

@tonysyu

I've used it a bit on a simple interactive plot and it worked perfectly for my purposes. And I can't see why there would be any corner cases.

Thanks for reviewing.

@WeatherGod
Collaborator

Agreed. Pulling...

@WeatherGod WeatherGod merged commit 91310f8 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 16, 2012
  1. @tonysyu

    Set slider to min/max constraint when value exceeds constraint.

    tonysyu authored
    Currently, when a slider's limits are constrained by another slider (using `slidermin/slidermax`), the slider will simply return unchanged when you move the slider beyond the limits.
    
    Instead, the slider should update to the min/max value when `closedmin/closedmax` attributes are True. This would match the behavior of the `valmin/valmax` limits.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/matplotlib/widgets.py
View
12 lib/matplotlib/widgets.py
@@ -307,11 +307,15 @@ def _update(self, event):
return
val = self.valmax
- if self.slidermin is not None:
- if val<=self.slidermin.val: return
+ if self.slidermin is not None and val <= self.slidermin.val:
+ if not self.closedmin:
+ return
+ val = self.slidermin.val
- if self.slidermax is not None:
- if val>=self.slidermax.val: return
+ if self.slidermax is not None and val >= self.slidermax.val:
+ if not self.closedmax:
+ return
+ val = self.slidermax.val
self.set_val(val)
Something went wrong with that request. Please try again.