@@ -330,8 +330,7 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
330
330
closedmin = True , closedmax = True , slidermin = None ,
331
331
slidermax = None , dragging = True , valstep = None ,
332
332
orientation = 'horizontal' , * , initcolor = 'r' ,
333
- track_color = 'lightgrey' , handle_facecolor = 'white' ,
334
- handle_edgecolor = '.75' , handle_size = 10 , ** kwargs ):
333
+ track_color = 'lightgrey' , handle_style = None , ** kwargs ):
335
334
"""
336
335
Parameters
337
336
----------
@@ -386,14 +385,16 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
386
385
The color of the background track. The track is accessible for
387
386
further styling via the *track* attribute.
388
387
389
- handle_facecolor : color, default: 'white'
390
- The facecolor of the circular slider handle.
388
+ handle_style : dict
389
+ Properties of the slider handle. Supported values are
391
390
392
- handle_edgecolor : color, default: '.75'
393
- The edgecolor of the circle slider handle.
394
-
395
- handle_size : int, default: 10
396
- The size of the circular slider handle in points.
391
+ ========= ===== ======= ========================================
392
+ Key Value Default Description
393
+ ========= ===== ======= ========================================
394
+ facecolor color 'white' The facecolor of the slider handle.
395
+ edgecolor color '.75' The edgecolor of the slider handle.
396
+ size int 10 The size of the slider handle in points.
397
+ ========= ===== ======= ========================================
397
398
398
399
Notes
399
400
-----
@@ -418,6 +419,15 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
418
419
valinit = valmin
419
420
self .val = valinit
420
421
self .valinit = valinit
422
+
423
+ marker_props = {}
424
+ defaults = {'facecolor' :'white' , 'edgecolor' :'.75' , 'size' :10 }
425
+ if handle_style is not None :
426
+ for k in ['facecolor' , 'edgecolor' , 'size' ]:
427
+ marker_props [f'marker{ k } ' ] = handle_style .get (k , defaults [k ])
428
+ else :
429
+ marker_props = {f'marker{ k } ' : v for k , v in defaults .items ()}
430
+
421
431
if orientation == 'vertical' :
422
432
self .track = Rectangle (
423
433
(.25 , 0 ), .5 , 1 ,
@@ -441,9 +451,7 @@ def __init__(self, ax, label, valmin, valmax, valinit=0.5, valfmt=None,
441
451
self ._handle , = ax .plot (
442
452
* handleXY ,
443
453
"o" ,
444
- markersize = handle_size ,
445
- markeredgecolor = handle_edgecolor ,
446
- markerfacecolor = handle_facecolor ,
454
+ ** marker_props ,
447
455
clip_on = False
448
456
)
449
457
@@ -598,9 +606,7 @@ def __init__(
598
606
valstep = None ,
599
607
orientation = "horizontal" ,
600
608
track_color = 'lightgrey' ,
601
- handle_facecolor = 'white' ,
602
- handle_edgecolor = '.75' ,
603
- handle_size = 10 ,
609
+ handle_style = None ,
604
610
** kwargs ,
605
611
):
606
612
"""
@@ -645,14 +651,16 @@ def __init__(
645
651
The color of the background track. The track is accessible for
646
652
further styling via the *track* attribute.
647
653
648
- handle_facecolor : color, default: 'white'
649
- The facecolor of the circular slider handle.
654
+ handle_style : dict
655
+ Properties of the slider handles. Supported values are
650
656
651
- handle_edgecolor : color, default: '.75'
652
- The edgecolor of the circular slider handles.
653
-
654
- handle_size : int, default: 10
655
- The size of the circular slider handles in points.
657
+ ========= ===== ======= =========================================
658
+ Key Value Default Description
659
+ ========= ===== ======= =========================================
660
+ facecolor color 'white' The facecolor of the slider handles.
661
+ edgecolor color '.75' The edgecolor of the slider handles.
662
+ size int 10 The size of the slider handles in points.
663
+ ========= ===== ======= =========================================
656
664
657
665
Notes
658
666
-----
@@ -675,6 +683,15 @@ def __init__(
675
683
valinit = self ._value_in_bounds (valinit )
676
684
self .val = valinit
677
685
self .valinit = valinit
686
+
687
+ marker_props = {}
688
+ defaults = {'facecolor' :'white' , 'edgecolor' :'.75' , 'size' :10 }
689
+ if handle_style is not None :
690
+ for k in ['facecolor' , 'edgecolor' , 'size' ]:
691
+ marker_props [f'marker{ k } ' ] = handle_style .get (k , defaults [k ])
692
+ else :
693
+ marker_props = {f'marker{ k } ' : v for k , v in defaults .items ()}
694
+
678
695
if orientation == "vertical" :
679
696
self .track = Rectangle (
680
697
(.25 , 0 ), .5 , 2 ,
@@ -699,17 +716,13 @@ def __init__(
699
716
ax .plot (
700
717
* handleXY_1 ,
701
718
"o" ,
702
- markersize = handle_size ,
703
- markeredgecolor = handle_edgecolor ,
704
- markerfacecolor = handle_facecolor ,
719
+ ** marker_props ,
705
720
clip_on = False
706
721
)[0 ],
707
722
ax .plot (
708
723
* handleXY_2 ,
709
724
"o" ,
710
- markersize = handle_size ,
711
- markeredgecolor = handle_edgecolor ,
712
- markerfacecolor = handle_facecolor ,
725
+ ** marker_props ,
713
726
clip_on = False
714
727
)[0 ]
715
728
]
0 commit comments