Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc44f7d

Browse files
committed
Don't change handle color on grab.
1 parent 6e89ee5 commit cc44f7d

File tree

1 file changed

+10
-47
lines changed

1 file changed

+10
-47
lines changed

lib/matplotlib/widgets.py

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,8 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
330330
closedmin=True, closedmax=True, slidermin=None,
331331
slidermax=None, dragging=True, valstep=None,
332332
orientation='horizontal', *, initcolor='r',
333-
track_color='lightgrey', handle_color_grabbed=None,
334-
handle_color_released='white', handle_edgecolor='.75',
335-
handle_size=10, **kwargs):
333+
track_color='lightgrey', handle_facecolor='white',
334+
handle_edgecolor='.75', handle_size=10, **kwargs):
336335
"""
337336
Parameters
338337
----------
@@ -387,12 +386,8 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
387386
The color of the backgrond track. The track is accesible for
388387
further styling via the *track* attribute.
389388
390-
handle_color_grabbed : color or None, default: None
391-
The color of the circular slider handle when grabbed. If *None*
392-
the same color as active part of the slider will be used.
393-
394-
handle_color_released : color, default: 'white'
395-
The color of the circular slider handle when released.
389+
handle_facecolor : color, default: 'white'
390+
The facecolor of the circular slider handle.
396391
397392
handle_edgecolor : color, default: '.75'
398393
The edgecolor of the circle slider handle.
@@ -448,16 +443,10 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
448443
"o",
449444
markersize=handle_size,
450445
markeredgecolor=handle_edgecolor,
451-
markerfacecolor=handle_color_released,
446+
markerfacecolor=handle_facecolor,
452447
clip_on=False
453448
)
454449

455-
self._handle_color_released = handle_color_released
456-
self._handle_edgecolor = handle_edgecolor
457-
if handle_color_grabbed is None:
458-
handle_color_grabbed = self.poly.get_facecolor()
459-
self._handle_color_grabbed = handle_color_grabbed
460-
461450
if orientation == 'vertical':
462451
self.label = ax.text(0.5, 1.02, label, transform=ax.transAxes,
463452
verticalalignment='bottom',
@@ -520,13 +509,7 @@ def _update(self, event):
520509
event.inaxes != self.ax)):
521510
self.drag_active = False
522511
event.canvas.release_mouse(self.ax)
523-
self._handle.set_markeredgecolor(self._handle_edgecolor)
524-
self._handle.set_markerfacecolor(self._handle_color_released)
525-
self.ax.figure.canvas.draw_idle()
526512
return
527-
if event.name == 'button_press_event':
528-
self._handle.set_markeredgecolor(self._handle_color_grabbed)
529-
self._handle.set_markerfacecolor(self._handle_color_grabbed)
530513
if self.orientation == 'vertical':
531514
val = self._value_in_bounds(event.ydata)
532515
else:
@@ -615,8 +598,7 @@ def __init__(
615598
valstep=None,
616599
orientation="horizontal",
617600
track_color='lightgrey',
618-
handle_color_grabbed=None,
619-
handle_color_released='white',
601+
handle_facecolor='white',
620602
handle_edgecolor='.75',
621603
handle_size=10,
622604
**kwargs,
@@ -667,8 +649,8 @@ def __init__(
667649
The color of the circular slider handles when grabbed. If *None*
668650
the same color as active part of the slider will be used.
669651
670-
handle_color_released : color, default: 'white'
671-
The color of the circular slider handles when released.
652+
handle_facecolor : color, default: 'white'
653+
The facecolor of the circular slider handle.
672654
673655
handle_edgecolor : color, default: '.75'
674656
The edgecolor of the circular slider handles.
@@ -722,25 +704,19 @@ def __init__(
722704
"o",
723705
markersize=handle_size,
724706
markeredgecolor=handle_edgecolor,
725-
markerfacecolor=handle_color_released,
707+
markerfacecolor=handle_facecolor,
726708
clip_on=False
727709
)[0],
728710
ax.plot(
729711
*handleXY_2,
730712
"o",
731713
markersize=handle_size,
732714
markeredgecolor=handle_edgecolor,
733-
markerfacecolor=handle_color_released,
715+
markerfacecolor=handle_facecolor,
734716
clip_on=False
735717
)[0]
736718
]
737719

738-
self._handle_color_released = handle_color_released
739-
self._handle_edgecolor = handle_edgecolor
740-
if handle_color_grabbed is None:
741-
handle_color_grabbed = self.poly.get_facecolor()
742-
self._handle_color_grabbed = handle_color_grabbed
743-
744720
if orientation == "vertical":
745721
self.label = ax.text(
746722
0.5,
@@ -835,10 +811,6 @@ def _update(self, event):
835811
):
836812
self.drag_active = False
837813
event.canvas.release_mouse(self.ax)
838-
self.ax.figure.canvas.draw_idle()
839-
for handle in self._handles:
840-
handle.set_markeredgecolor(self._handle_edgecolor)
841-
handle.set_markerfacecolor(self._handle_color_released)
842814
self._active_handle = None
843815
return
844816

@@ -851,16 +823,7 @@ def _update(self, event):
851823
# these checks ensure smooth behavior if the handles swap which one
852824
# has a higher value. i.e. if one is dragged over and past the other.
853825
if handle is not self._active_handle:
854-
if self._active_handle is not None:
855-
self._active_handle.set_markeredgecolor(
856-
self._handle_edgecolor
857-
)
858-
self._active_handle.set_markerfacecolor(
859-
self._handle_color_released
860-
)
861826
self._active_handle = handle
862-
self._active_handle.set_markeredgecolor(self._handle_color_grabbed)
863-
self._active_handle.set_markerfacecolor(self._handle_color_grabbed)
864827

865828
if self.orientation == "vertical":
866829
self._update_val_from_pos(event.ydata)

0 commit comments

Comments
 (0)