Slider package: provide multiple slider implementation (simple, xy, boundary...)
# Jump directly to Examples
Slider package: provide multiple slider implementation (simple, xy, boundary...)
-
class pymt.ui.widgets.slider.MTSlider(**kwargs)
Bases: pymt.ui.widgets.widget.MTWidget
MTSlider is an implementation of a scrollbar using MTWidget.
| Parameters : |
- min : int, default is 0
Minimum value of slider
- max : int, default is 100
Maximum value of slider
- orientation : str, default is vertical
Type of orientation, can be ‘horizontal’ or ‘vertical’
- value : int, default is min
Default value of slider
- value_show : bool, default to False
Show value on the slider
- value_format : str, default to ‘%d’
If value is showed, this is the format used for drawing value
- value_config : dict, default to {}
Settings to pass to drawLabel()
|
| Styles : |
- slider-color : color
Color of the slider
- slider-color-down : color
Color of the slider when pressed down (same as slider-color by default)
- bg-color : color
Background color of the slider
- padding : int
Padding of content
|
| Events : |
- on_value_change (value)
Fired when slider value is changed
|
-
value
Value of the slider
-
class pymt.ui.widgets.slider.MTXYSlider(**kwargs)
Bases: pymt.ui.widgets.widget.MTWidget
MTXYSlider is an implementation of a 2D slider using MTWidget.
| Parameters : |
- min_x : int, default is 20
Minimum value of slider
- max_x : int, default is 100
Maximum value of slider
- min_y : int, default is 20
Minimum value of slider
- max_y : int, default is 100
Maximum value of slider
- radius : int, default is 200
Radius of the slider handle
- value_x : int, default is min_x
Default X value of slider
- value_y : int, default is min_y
Default Y value of slider
|
| Styles : |
- slider-color : color
Color of the slider
- bg-color : color
Background color of the slider
|
| Events : |
- on_value_change (value X, value Y)
Fired when slider x/y value is changed
|
-
value_x
Value of the slider (x axis)
-
value_y
Value of the slider (y axis)
-
class pymt.ui.widgets.slider.MTBoundarySlider(**kwargs)
Bases: pymt.ui.widgets.widget.MTWidget
MTBoundarySlider is a widget that allows you to select minimum and maximum values.
| Parameters : |
- min : int, default is 0
Minimum value of slider
- max : int, default is 100
Maximum value of slider
- orientation : str, default is vertical
Type of orientation, can be ‘horizontal’ or ‘vertical’
- value_max : int, default is max - (max/4)
The default maximum value
- value_min : int, the default is min + (max/4)
The default minumum value
- showtext : boolean, defaults to false
If true, the widget will show the min/max value
|
| Styles : |
- slider-color : color
Color of the slider
- bg-color : color
Background color of the slider
|
| Events : |
- on_value_change (value_min, value_max)
Fired when min or max is changed
|
-
get_value()
Scale the value to the minimum and maximum system set by the user
-
class pymt.ui.widgets.slider.MTMultiSlider(**kwargs)
Bases: pymt.ui.widgets.widget.MTWidget
Multi slider widget look like an equalizer widget.
| Parameters : |
- sliders : int, default to 20
Number of sliders
- spacing : int, default to 1
Spacing between slider
- init_value : float, default to 0.5
Start value of all sliders
|
| Styles : |
- slider-color : color
Color of slider
- bg-color : color
Background color of slider
|
| Events : |
- on_value_change (values)
Fired when the value of one slider change
|
-
sliders
Get/set the number of sliders
Examples
File ui_widgets_slider_xy.py
from pymt import *
# create a slider from 0.-1.
sl = MTXYSlider()
@sl.event
def on_value_change(x, y):
print 'Slider value change', x, y
runTouchApp(sl)
File ui_widgets_slider_multi.py
from pymt import *
sl = MTMultiSlider(init_value=0.1)
@sl.event
def on_value_change(values):
print 'Slider values change: ', values
runTouchApp(sl)
File ui_widgets_slider.py
from pymt import *
# create a slider from 0.-1. and make it change colors when pressed
sl = MTSlider(min=0., max=1., style={'slider-color-down':(.5,1,0,1)})
@sl.event
def on_value_change(value):
print 'Slider value change', value
runTouchApp(sl)
File ui_widgets_slider_circular.py
# example with a scatter plane + multiple circular slider
# add a css to see bounding box of circular slider
from pymt import *
css_add_sheet('circularslider { draw-background: 1; }')
s = MTScatterPlane()
m = MTBoxLayout(pos=(100,100))
c = MTCircularSlider(radius=100.0, rotation=200, value=50, thickness=20)
m.add_widget(c)
c2 = MTCircularSlider(radius=50.0, rotation=90, value=75)
m.add_widget(c2)
c3 = MTCircularSlider(radius=80.0, value=25, padding=8, thickness=50)
c3.value = 100
c.value = 25
c.connect('on_value_change', c2, 'value')
c.connect('on_value_change', c3, 'value')
m.add_widget(c3)
s.add_widget(m)
runTouchApp(s)
File ui_widgets_slider_boundary.py
from pymt import *
sl = MTBoundarySlider(value=50)
@sl.event
def on_value_change(vmin, vmax):
print 'Slider values change: ', vmin, ' - ', vmax
runTouchApp(sl)