dhxpyt.slider.slider_config
1from typing import Any, Callable, Dict, Optional, Union 2 3 4 5class SliderConfig: 6 """ 7 Configuration class for the Slider widget. 8 """ 9 10 def __init__(self, 11 min: float, 12 max: float, 13 step: float = 1, 14 value: Union[float, str, list] = None, 15 css: str = None, 16 helpMessage: str = None, 17 hiddenLabel: bool = None, 18 inverse: bool = None, 19 label: str = None, 20 labelPosition: str = None, 21 labelWidth: Union[str, int] = None, 22 majorTick: float = None, 23 mode: str = "horizontal", 24 range: bool = None, 25 tick: float = None, 26 tickTemplate: Callable[[float], str] = None, 27 tooltip: bool = True): 28 """ 29 Initializes the SliderConfig. 30 31 :param min: (Required) The minimal value of slider. 32 :param max: (Required) The maximal value of slider. 33 :param step: (Optional) The step the slider thumb will be moved with. Default is 1. 34 :param value: (Optional) The value the thumb will be set at on initialization of the slider. 35 :param css: (Optional) Adds style classes for the component. 36 :param helpMessage: (Optional) Adds an icon with a question mark next to Slider. 37 :param hiddenLabel: (Optional) Adds a hidden label for a Slider that will be used while sending a form to the server. 38 :param inverse: (Optional) Enables/disables the inverse slider mode. 39 :param label: (Optional) Specifies the label of a slider. 40 :param labelPosition: (Optional) Defines the position of a label of a slider ("left" | "top"). 41 :param labelWidth: (Optional) Sets the width of a label. 42 :param majorTick: (Optional) Sets interval of rendering numeric values on the slider scale. 43 :param mode: (Optional) The direction of the Slider scale ("vertical" | "horizontal"). Default is "horizontal". 44 :param range: (Optional) Enables/disables the possibility to select a range of values on the slider. 45 :param tick: (Optional) Sets the interval of steps for rendering the slider scale. 46 :param tickTemplate: (Optional) Sets a template for rendering values on the scale. 47 :param tooltip: (Optional) Enables a tooltip on hovering over the slider thumb. Default is True. 48 """ 49 self.min = min 50 self.max = max 51 self.step = step 52 self.value = value 53 self.css = css 54 self.helpMessage = helpMessage 55 self.hiddenLabel = hiddenLabel 56 self.inverse = inverse 57 self.label = label 58 self.labelPosition = labelPosition 59 self.labelWidth = labelWidth 60 self.majorTick = majorTick 61 self.mode = mode 62 self.range = range 63 self.tick = tick 64 self.tickTemplate = tickTemplate 65 self.tooltip = tooltip 66 67 def to_dict(self) -> Dict[str, Any]: 68 """ 69 Converts the SliderConfig into a dictionary format. 70 """ 71 config_dict = { 72 'min': self.min, 73 'max': self.max, 74 'step': self.step, 75 'value': self.value, 76 'css': self.css, 77 'helpMessage': self.helpMessage, 78 'hiddenLabel': self.hiddenLabel, 79 'inverse': self.inverse, 80 'label': self.label, 81 'labelPosition': self.labelPosition, 82 'labelWidth': self.labelWidth, 83 'majorTick': self.majorTick, 84 'mode': self.mode, 85 'range': self.range, 86 'tick': self.tick, 87 'tooltip': self.tooltip, 88 } 89 # Handle the tickTemplate function 90 if self.tickTemplate: 91 # Since tickTemplate is a function, we can't serialize it to JSON 92 # We'll store it separately and handle it in the Slider class 93 config_dict['tickTemplate'] = self.tickTemplate 94 95 # Remove None values 96 config_dict = {k: v for k, v in config_dict.items() if v is not None} 97 return config_dict
class
SliderConfig:
6class SliderConfig: 7 """ 8 Configuration class for the Slider widget. 9 """ 10 11 def __init__(self, 12 min: float, 13 max: float, 14 step: float = 1, 15 value: Union[float, str, list] = None, 16 css: str = None, 17 helpMessage: str = None, 18 hiddenLabel: bool = None, 19 inverse: bool = None, 20 label: str = None, 21 labelPosition: str = None, 22 labelWidth: Union[str, int] = None, 23 majorTick: float = None, 24 mode: str = "horizontal", 25 range: bool = None, 26 tick: float = None, 27 tickTemplate: Callable[[float], str] = None, 28 tooltip: bool = True): 29 """ 30 Initializes the SliderConfig. 31 32 :param min: (Required) The minimal value of slider. 33 :param max: (Required) The maximal value of slider. 34 :param step: (Optional) The step the slider thumb will be moved with. Default is 1. 35 :param value: (Optional) The value the thumb will be set at on initialization of the slider. 36 :param css: (Optional) Adds style classes for the component. 37 :param helpMessage: (Optional) Adds an icon with a question mark next to Slider. 38 :param hiddenLabel: (Optional) Adds a hidden label for a Slider that will be used while sending a form to the server. 39 :param inverse: (Optional) Enables/disables the inverse slider mode. 40 :param label: (Optional) Specifies the label of a slider. 41 :param labelPosition: (Optional) Defines the position of a label of a slider ("left" | "top"). 42 :param labelWidth: (Optional) Sets the width of a label. 43 :param majorTick: (Optional) Sets interval of rendering numeric values on the slider scale. 44 :param mode: (Optional) The direction of the Slider scale ("vertical" | "horizontal"). Default is "horizontal". 45 :param range: (Optional) Enables/disables the possibility to select a range of values on the slider. 46 :param tick: (Optional) Sets the interval of steps for rendering the slider scale. 47 :param tickTemplate: (Optional) Sets a template for rendering values on the scale. 48 :param tooltip: (Optional) Enables a tooltip on hovering over the slider thumb. Default is True. 49 """ 50 self.min = min 51 self.max = max 52 self.step = step 53 self.value = value 54 self.css = css 55 self.helpMessage = helpMessage 56 self.hiddenLabel = hiddenLabel 57 self.inverse = inverse 58 self.label = label 59 self.labelPosition = labelPosition 60 self.labelWidth = labelWidth 61 self.majorTick = majorTick 62 self.mode = mode 63 self.range = range 64 self.tick = tick 65 self.tickTemplate = tickTemplate 66 self.tooltip = tooltip 67 68 def to_dict(self) -> Dict[str, Any]: 69 """ 70 Converts the SliderConfig into a dictionary format. 71 """ 72 config_dict = { 73 'min': self.min, 74 'max': self.max, 75 'step': self.step, 76 'value': self.value, 77 'css': self.css, 78 'helpMessage': self.helpMessage, 79 'hiddenLabel': self.hiddenLabel, 80 'inverse': self.inverse, 81 'label': self.label, 82 'labelPosition': self.labelPosition, 83 'labelWidth': self.labelWidth, 84 'majorTick': self.majorTick, 85 'mode': self.mode, 86 'range': self.range, 87 'tick': self.tick, 88 'tooltip': self.tooltip, 89 } 90 # Handle the tickTemplate function 91 if self.tickTemplate: 92 # Since tickTemplate is a function, we can't serialize it to JSON 93 # We'll store it separately and handle it in the Slider class 94 config_dict['tickTemplate'] = self.tickTemplate 95 96 # Remove None values 97 config_dict = {k: v for k, v in config_dict.items() if v is not None} 98 return config_dict
Configuration class for the Slider widget.
SliderConfig( min: float, max: float, step: float = 1, value: Union[float, str, list] = None, css: str = None, helpMessage: str = None, hiddenLabel: bool = None, inverse: bool = None, label: str = None, labelPosition: str = None, labelWidth: Union[str, int] = None, majorTick: float = None, mode: str = 'horizontal', range: bool = None, tick: float = None, tickTemplate: Callable[[float], str] = None, tooltip: bool = True)
11 def __init__(self, 12 min: float, 13 max: float, 14 step: float = 1, 15 value: Union[float, str, list] = None, 16 css: str = None, 17 helpMessage: str = None, 18 hiddenLabel: bool = None, 19 inverse: bool = None, 20 label: str = None, 21 labelPosition: str = None, 22 labelWidth: Union[str, int] = None, 23 majorTick: float = None, 24 mode: str = "horizontal", 25 range: bool = None, 26 tick: float = None, 27 tickTemplate: Callable[[float], str] = None, 28 tooltip: bool = True): 29 """ 30 Initializes the SliderConfig. 31 32 :param min: (Required) The minimal value of slider. 33 :param max: (Required) The maximal value of slider. 34 :param step: (Optional) The step the slider thumb will be moved with. Default is 1. 35 :param value: (Optional) The value the thumb will be set at on initialization of the slider. 36 :param css: (Optional) Adds style classes for the component. 37 :param helpMessage: (Optional) Adds an icon with a question mark next to Slider. 38 :param hiddenLabel: (Optional) Adds a hidden label for a Slider that will be used while sending a form to the server. 39 :param inverse: (Optional) Enables/disables the inverse slider mode. 40 :param label: (Optional) Specifies the label of a slider. 41 :param labelPosition: (Optional) Defines the position of a label of a slider ("left" | "top"). 42 :param labelWidth: (Optional) Sets the width of a label. 43 :param majorTick: (Optional) Sets interval of rendering numeric values on the slider scale. 44 :param mode: (Optional) The direction of the Slider scale ("vertical" | "horizontal"). Default is "horizontal". 45 :param range: (Optional) Enables/disables the possibility to select a range of values on the slider. 46 :param tick: (Optional) Sets the interval of steps for rendering the slider scale. 47 :param tickTemplate: (Optional) Sets a template for rendering values on the scale. 48 :param tooltip: (Optional) Enables a tooltip on hovering over the slider thumb. Default is True. 49 """ 50 self.min = min 51 self.max = max 52 self.step = step 53 self.value = value 54 self.css = css 55 self.helpMessage = helpMessage 56 self.hiddenLabel = hiddenLabel 57 self.inverse = inverse 58 self.label = label 59 self.labelPosition = labelPosition 60 self.labelWidth = labelWidth 61 self.majorTick = majorTick 62 self.mode = mode 63 self.range = range 64 self.tick = tick 65 self.tickTemplate = tickTemplate 66 self.tooltip = tooltip
Initializes the SliderConfig.
Parameters
- min: (Required) The minimal value of slider.
- max: (Required) The maximal value of slider.
- step: (Optional) The step the slider thumb will be moved with. Default is 1.
- value: (Optional) The value the thumb will be set at on initialization of the slider.
- css: (Optional) Adds style classes for the component.
- helpMessage: (Optional) Adds an icon with a question mark next to Slider.
- hiddenLabel: (Optional) Adds a hidden label for a Slider that will be used while sending a form to the server.
- inverse: (Optional) Enables/disables the inverse slider mode.
- label: (Optional) Specifies the label of a slider.
- labelPosition: (Optional) Defines the position of a label of a slider ("left" | "top").
- labelWidth: (Optional) Sets the width of a label.
- majorTick: (Optional) Sets interval of rendering numeric values on the slider scale.
- mode: (Optional) The direction of the Slider scale ("vertical" | "horizontal"). Default is "horizontal".
- range: (Optional) Enables/disables the possibility to select a range of values on the slider.
- tick: (Optional) Sets the interval of steps for rendering the slider scale.
- tickTemplate: (Optional) Sets a template for rendering values on the scale.
- tooltip: (Optional) Enables a tooltip on hovering over the slider thumb. Default is True.
def
to_dict(self) -> Dict[str, Any]:
68 def to_dict(self) -> Dict[str, Any]: 69 """ 70 Converts the SliderConfig into a dictionary format. 71 """ 72 config_dict = { 73 'min': self.min, 74 'max': self.max, 75 'step': self.step, 76 'value': self.value, 77 'css': self.css, 78 'helpMessage': self.helpMessage, 79 'hiddenLabel': self.hiddenLabel, 80 'inverse': self.inverse, 81 'label': self.label, 82 'labelPosition': self.labelPosition, 83 'labelWidth': self.labelWidth, 84 'majorTick': self.majorTick, 85 'mode': self.mode, 86 'range': self.range, 87 'tick': self.tick, 88 'tooltip': self.tooltip, 89 } 90 # Handle the tickTemplate function 91 if self.tickTemplate: 92 # Since tickTemplate is a function, we can't serialize it to JSON 93 # We'll store it separately and handle it in the Slider class 94 config_dict['tickTemplate'] = self.tickTemplate 95 96 # Remove None values 97 config_dict = {k: v for k, v in config_dict.items() if v is not None} 98 return config_dict
Converts the SliderConfig into a dictionary format.