rotary_slider
Displayio Layout Rotary Slider Widget
Author(s): Jose D. Montoya
- class rotary_slider.Slider(*args: Any, **kwargs: Any)[source]
- Parameters:
x (int) – pixel position, defaults to 0
y (int) – pixel position, defaults to 0
radius (int) – radius of the rotary slider in pixels. It is recommended to use 100
touch_padding (int) – the width of an additional border surrounding the switch that extends the touch response boundary. Defaults to
0anchor_point (Tuple[float, float]) – starting point for the annotation line, where
anchor_pointis an (A,B) tuple in relative units of the size of the widget, for example (0.0, 0.0) is the upper left corner, and (1.0, 1.0) is the lower right corner of the widget. Ifanchor_pointisNone, thenanchored_positionis used to set the annotation line starting point, in widget size relative units. Defaults to(0.0, 0.0)anchored_position (Tuple[int, int]) – pixel position starting point for the annotation line where
anchored_positionis an (x,y) tuple in pixel units relative to the upper left corner of the widget, in pixel units (default is None).
Quickstart: Importing and using RotarySlider
Here is one way of importing the
Sliderclass so you can use it as the nameSlider:from rotary_slider import Slider
Now you can create a Rotary Slider at pixel position x=20, y=30 using:
my_slider=Slider(x=20, y=30)
Once your setup your display, you can now add
my_sliderto your display using:display.show(my_slider) # add the group to the display
If you want to have multiple display elements, you can create a group and then append the slider and the other elements to the group. Then, you can add the full group to the display as in this example:
my_slider= Slider(20, 30) my_group = displayio.Group() # make a group my_group.append(my_slider) # Add my_slider to the group # # Append other display elements to the group # display.show(my_group) # add the group to the display
Summary: Slider Features and input variables
The
Sliderwidget has some options for controlling its position, visible appearance, and value through a collection of input variables:position:
x,yoranchor_pointandanchored_positionsize:
radiusknob color:
fill_color,outline_colorbackground color:
background_colortouch boundaries:
touch_paddingdefines the number of additional pixels surrounding the switch that should respond to a touch. (Note: Thetouch_paddingvariable updates thetouch_boundaryControl class variable. The definition of thetouch_boundaryis used to determine the region on the Widget that returnsTruein thewhen_insidefunction.)