@@ -52,29 +52,30 @@ class Slider(Widget, Control):
52
52
:param int x: pixel position, defaults to 0
53
53
:param int y: pixel position, defaults to 0
54
54
:param int width: width of the slider in pixels. It is recommended to use 100
55
- the height will auto-size relative to the width, defaults to 100
55
+ the height will auto-size relative to the width. Defaults to :const:` 100`
56
56
:param int height: height of the slider in pixels, defaults to 40 pixels
57
57
:param int touch_padding: the width of an additional border surrounding the switch
58
58
that extends the touch response boundary, defaults to 0
59
59
60
60
:param anchor_point: starting point for the annotation line, where ``anchor_point`` is
61
61
an (A,B) tuple in relative units of the size of the widget, for example (0.0, 0.0) is
62
- the upper left corner, and (1.0, 1.0) is the lower right corner of the widget.
63
- If ``anchor_point`` is `None`, then ``anchored_position`` is used to set the
64
- annotation line starting point, in widget size relative units (default is (0.0, 0.0)).
62
+ the upper left corner, and (1.0, 1.0) is the lower right corner of the widget.
63
+ If :attr:`anchor_point` is `None`, then :attr:`anchored_position` is used to set the
64
+ annotation line starting point, in widget size relative units.
65
+ Defaults to :const:`(0.0, 0.0)`
65
66
:type anchor_point: Tuple[float, float]
66
67
67
68
:param anchored_position: pixel position starting point for the annotation line
68
- where `` anchored_position` ` is an (x,y) tuple in pixel units relative to the
69
+ where :attr:` anchored_position` is an (x,y) tuple in pixel units relative to the
69
70
upper left corner of the widget, in pixel units (default is None).
70
71
:type anchored_position: Tuple[int, int]
71
72
72
73
:param fill_color: (*RGB tuple or 24-bit hex value*) slider fill color, default
73
- is `` (66, 44, 66)` ` gray.
74
+ is :const:` (66, 44, 66)` gray.
74
75
:param outline_color: (*RGB tuple or 24-bit hex value*) slider outline color,
75
- default is `` (30, 30, 30)` ` dark gray.
76
+ default is :const:` (30, 30, 30)` dark gray.
76
77
:param background_color: (*RGB tuple or 24-bit hex value*) background color,
77
- default is `` (255, 255, 255)` ` white
78
+ default is :const:` (255, 255, 255)` white
78
79
79
80
:param int switch_stroke: outline stroke width for the switch and background, in pixels,
80
81
default is 2
@@ -83,7 +84,7 @@ class Slider(Widget, Control):
83
84
84
85
**Quickstart: Importing and using Slider**
85
86
86
- Here is one way of importing the `` Slider` ` class so you can use it as
87
+ Here is one way of importing the `Slider` class so you can use it as
87
88
the name ``Slider``:
88
89
89
90
.. code-block:: python
@@ -124,20 +125,20 @@ class Slider(Widget, Control):
124
125
The ``Slider`` widget has some options for controlling its position, visible appearance,
125
126
and value through a collection of input variables:
126
127
127
- - **position**: ``x` `, ``y`` or ``anchor_point`` and ``anchored_position``
128
+ - **position**: :const:`x `, ``y`` or ``anchor_point`` and ``anchored_position``
128
129
129
- - **size**: `` width` ` and ``height`` (recommend to leave ``height`` = None to use
130
+ - **size**: :const:` width` and ``height`` (recommend to leave ``height`` = None to use
130
131
preferred aspect ratio)
131
132
132
- - **switch color**: `` fill_color``, `` outline_color` `
133
+ - **switch color**: :const:` fill_color`, :const:` outline_color`
133
134
134
- - **background color**: `` background_color` `
135
+ - **background color**: :const:` background_color`
135
136
136
- - **linewidths**: `` switch_stroke` `
137
+ - **linewidths**: :const:` switch_stroke`
137
138
138
139
- **value**: Set ``value`` to the initial value (True or False)
139
140
140
- - **touch boundaries**: `` touch_padding` ` defines the number of additional pixels
141
+ - **touch boundaries**: :attr:` touch_padding` defines the number of additional pixels
141
142
surrounding the switch that should respond to a touch. (Note: The ``touch_padding``
142
143
variable updates the ``touch_boundary`` Control class variable. The definition of
143
144
the ``touch_boundary`` is used to determine the region on the Widget that returns
@@ -156,6 +157,15 @@ class Slider(Widget, Control):
156
157
157
158
"""
158
159
160
+ # TODO: [ ] graphics: The slider can go outside the backgroundbox’s [BUG]
161
+ # [ ] range, if slid all the way to the right side.touch behavior:
162
+ # The slider does not “center” on the touch point [IMPROVEMENT]
163
+ # [ ] Touch_Down vs Touch_Move [LONG-THERM]
164
+ # Not designed as drag and move. Is desired like
165
+ # this to point and select. Maybe could be a parameter
166
+ # [ ] Touch MOVE outside box [IMPROVEMENT]
167
+ # [ ] Slow Down With movement. No design to act as drag and move [LONG-THERM]
168
+
159
169
# pylint: disable=too-many-instance-attributes, too-many-arguments, too-many-locals
160
170
# pylint: disable=too-many-branches, too-many-statements
161
171
def __init__ (
@@ -190,8 +200,9 @@ def __init__(
190
200
self ._height = self .height
191
201
192
202
# pylint: disable=access-member-before-definition)
203
+
193
204
if self ._width is None :
194
- self ._width = 50
205
+ self ._width = 100
195
206
else :
196
207
self ._width = self .width
197
208
@@ -288,7 +299,7 @@ def _draw_position(self, position):
288
299
# Get the position offset from the motion function
289
300
x_offset , y_offset = self ._get_offset_position (position )
290
301
291
- # Update the switch and text x- and y-positions
302
+ # Update the switch x- and y-positions
292
303
self ._switch_handle .x = self ._switch_initial_x + x_offset
293
304
self ._switch_handle .y = self ._switch_initial_y + y_offset
294
305
@@ -297,10 +308,14 @@ def when_selected(self, touch_point):
297
308
Manages internal logic when widget is selected
298
309
"""
299
310
300
- touch_x = touch_point [0 ] - self .x
301
- touch_y = touch_point [1 ] - self .y
311
+ if touch_point [0 ] <= self .x + self ._knob_width :
312
+ print ("maayor" , touch_point [0 ])
313
+ touch_x = touch_point [0 ] - self .x
314
+ else :
315
+ print ("menor" , touch_point [0 ])
316
+ touch_x = touch_point [0 ] - self .x - self ._knob_width
302
317
303
- self . _switch_handle . x = touch_x
318
+ touch_y = touch_point [ 1 ] - self . y
304
319
305
320
super ().selected ((touch_x , touch_y , 0 ))
306
321
return self ._switch_handle .x
0 commit comments