SourceClass Slider
from egui import Sliderclass Slider:Control a number with a slider.
The slider range defines the values you get when pulling the slider to the far edges.
By default all values are clamped to this range, even when not interacted with.
You can change this behavior by passing False to Slider.clamping.
The range can include any numbers, and go from low-to-high or from high-to-low.
The slider consists of three parts: a slider, a value display, and an optional text.
The user can click the value display to edit its value. It can be turned off with .show_value(False).
The default Slider size is set by egui.style.Spacing.slider_width.
Methods§
Sourcedef binary(self, /, min_width: int, twos_complement: bool) -> Slider§
Display and parse the number as a binary integer. See ValueFormat.binary.
def clamp_to_range(self, /, clamp_to_range: bool) -> Slider§
Sourcedef clamping(self, /, clamping: SliderClamping) -> Slider§
Controls when the values will be clamped to the range.
With .clamping(SliderClamping.Always) (default)
With .clamping(SliderClamping.Edits)
With .clamping(SliderClamping.Never)
Sourcedef custom_formatter(self, /, formatter: Any) -> Slider§
Set custom formatter defining how numbers are converted into text.
A custom formatter takes a float for the numeric value and a RangeInclusive<int> representing
the decimal range i.e. minimum and maximum number of decimal places shown.
The default formatter is egui.Style.number_formatter.
See also: Slider.custom_parser
Sourcedef custom_parser(self, /, parser: Any) -> Slider§
Set custom parser defining how the text input is parsed into a number.
A custom parser takes an str to parse into a number and returns Some if it was successfully parsed
or None otherwise.
See also: Slider.custom_formatter
Sourcedef drag_value_speed(self, /, drag_value_speed: float) -> Slider§
When dragging the value, how fast does it move?
Unit: values per point (logical pixel).
See also egui.DragValue.speed.
By default this is the same speed as when dragging the slider, but you can change it here to for instance have a much finer control by dragging the slider value rather than the slider itself.
Sourcedef fixed_decimals(self, /, num_decimals: int) -> Slider§
Set an exact number of decimals to display.
Values will also be rounded to this number of decimals. Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use "smart aim" to help the user select nice, round values.
Source@staticmethod
def from_get_set(min: float, max: float, get_set_value: Any) -> Slider§
Creates a slider over a value that cannot be borrowed directly.
The closure is called with None to read the value and with Some(new_value) to write it,
and returns the value either way.
Sourcedef handle_shape(self, /, handle_shape: HandleShape) -> Slider§
Change the shape of the slider handle
This setting can be enabled globally for all sliders with egui.Visuals.handle_shape.
Changing it here will override the above setting ONLY for this individual slider.
Sourcedef hexadecimal(self, /, min_width: int, twos_complement: bool, upper: bool) -> Slider§
Display and parse the number as a hexadecimal integer. See ValueFormat.hexadecimal.
Sourcedef integer(self, /) -> Slider§
Helper: equivalent to egui.precision(0).smallest_positive(1.0).
If you use one of the integer constructors (e.g. Slider.int) this is called for you,
but if you want to have a slider for picking integer values in an Slider.float, use this.
Sourcedef largest_finite(self, /, largest_finite: float) -> Slider§
For logarithmic sliders, the largest positive value we are interested in
before the slider switches to INFINITY, if that is the higher end.
Default: INFINITY.
Sourcedef logarithmic(self, /, logarithmic: bool) -> Slider§
Make this a logarithmic slider.
This is great for when the slider spans a huge range, e.g. from one to a million. The default is OFF.
Sourcedef max_decimals(self, /, max_decimals: int) -> Slider§
Set a maximum number of decimals to display.
Values will also be rounded to this number of decimals. Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use "smart aim" to help the user select nice, round values.
Sourcedef max_decimals_opt(self, /, max_decimals: int |None) -> Slider§
Set the maximum number of decimals to display, or None to let the widget pick.
Values will also be rounded to this number of decimals when it is set.
Sourcedef min_decimals(self, /, min_decimals: int) -> Slider§
Set a minimum number of decimals to display.
Normally you don't need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use "smart aim" to help the user select nice, round values.
Sourcedef octal(self, /, min_width: int, twos_complement: bool) -> Slider§
Display and parse the number as an octal integer. See ValueFormat.octal.
Sourcedef orientation(self, /, orientation: SliderOrientation) -> Slider§
Vertical or horizontal slider? The default is horizontal.
Sourcedef prefix(self, /, prefix: str) -> Slider§
Show a prefix before the number, e.g. "x: ".
Goes in front of any prefix already set, so .prefix("b").prefix("a") shows ab.
def show(self, /, ui: Ui) -> Response§
Sourcedef show_value(self, /, show_value: bool) -> Slider§
Control whether or not the slider shows the current value.
Default: True.
Sourcedef smallest_positive(self, /, smallest_positive: float) -> Slider§
For logarithmic sliders that includes zero:
what is the smallest positive value you want to be able to select?
The default is 1 for integer sliders and 1e-6 for real sliders.
Sourcedef smart_aim(self, /, smart_aim: bool) -> Slider§
Turn smart aim on/off. Default is ON. There is almost no point in turning this off.
Sourcedef step_by(self, /, step: float) -> Slider§
Sets the minimal change of the value.
Value 0.0 effectively disables the feature. If the new value is out of range
and clamp_to_range is enabled, you would not have the ability to change the value.
Default: 0.0 (disabled).
Sourcedef suffix(self, /, suffix: str) -> Slider§
Add a suffix to the number, this can be e.g. a unit ("°" or " m").
Goes after any suffix already set, so .suffix("a").suffix("b") shows ab.
Sourcedef text(self, /, text: Any) -> Slider§
Show a text next to the slider (e.g. explaining what the slider controls).
Sourcedef text_color(self, /, text_color: Color32) -> Slider§
Set the color of the text shown next to the slider.
Sourcedef trailing_fill(self, /, trailing_fill: bool) -> Slider§
Display trailing color behind the slider's circle. Default is OFF.
This setting can be enabled globally for all sliders with egui.Visuals.slider_trailing_fill.
Toggling it here will override the above setting ONLY for this individual slider.
The fill color will be taken from selection.bg_fill in your egui.Visuals, the same as a egui.ProgressBar.
Sourcedef update_while_editing(self, /, update: bool) -> Slider§
Update the value on each key press when text-editing the value.
Default: True.
If False, the value will only be updated when user presses enter or deselects the value.
Sourcedef vertical(self, /) -> Slider§
Make this a vertical slider.