def __init__(self, placeholder: str = 'Enter text', size: str = 'default', area: bool = False, autosize: bool = False, disabled: bool = False) -> None: """Create a text box. Parameters ---------- placeholder : str, optional Initial text that appears. size : 'default', 'large', 'small', optional Size of the text box. area : bool, optional Create a text area if True else create a single line input. autosize : bool, optional Automatically size the widget based on the content. disabled : bool, optional Disable input to the widget. References ---------- https://ant.design/components/input/ """ super().__init__() self._comp = self._tag.format(area='textarea' if area else 'text', autosize=jsbool(autosize), disabled=jsbool(disabled), placeholder=placeholder, size=size)
def __init__(self, placeholder: str = 'Enter text', size: str = 'default', area: bool = False, autosize: bool = False, disabled: bool = False) -> None: """Create a text box. Parameters ---------- placeholder : str, optional Initial text that appears. size : 'default', 'large', 'small', optional Size of the text box. area : bool, optional Create a text area if True else create a single line input. autosize : bool, optional Automatically size the widget based on the content. disabled : bool, optional Disable input to the widget. References ---------- https://ant.design/components/input/ """ super().__init__() self._comp = self._tag.format( area='textarea' if area else 'text', autosize=jsbool(autosize), disabled=jsbool(disabled), placeholder=placeholder, size=size )
def __init__(self, date_type=False, month_type=False, range_type=False, caption=None): super(_DatePickers, self).__init__(caption=caption) self._comp = self._tag.format( date_type=jsbool(date_type), month_type=jsbool(month_type), range_type=jsbool(range_type) )
def __init__(self, date_type: bool = False, month_type: bool = False, range_type: bool = False) -> None: super().__init__() self._comp = self._tag.format(date_type=jsbool(date_type), month_type=jsbool(month_type), range_type=jsbool(range_type))
def __init__(self, date_type: bool = False, month_type: bool = False, range_type: bool = False) -> None: super().__init__() self._comp = self._tag.format( date_type=jsbool(date_type), month_type=jsbool(month_type), range_type=jsbool(range_type) )
def __init__(self, date_type: bool = False, month_type: bool = False, range_type: bool = False, caption: Optional[str] = None) -> None: super().__init__(caption=caption) self._comp = self._tag.format( date_type=jsbool(date_type), month_type=jsbool(month_type), range_type=jsbool(range_type) )
def __init__( self, start: Optional[Union[float, Sequence[float]]] = None, ranged: bool = False, minimum: float = 0, maximum: float = 100, step: float = 1, vertical: bool = False, ) -> None: """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. ranged : bool, optional If this is a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. step : number, optional Step size. vertical : bool, optional If True, the slider will be vertical References ---------- https://ant.design/components/slider/ """ super().__init__() if start is None: if ranged: start = [minimum, maximum] else: start = minimum elif isinstance(start, Sequence): if len(start) > 2: raise ValueError('start cannot be more than 2 numbers') start = list(start) ranged = True self._comp = self._tag.format( range=jsbool(ranged), minimum=minimum, maximum=maximum, start=start, step=step, marks={ minimum: str(minimum), maximum: str(maximum) }, vertical=jsbool(vertical), )
def __init__(self, start=None, ranged=False, minimum=0, maximum=100, step=1, vertical=False, caption=None): """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. ranged : bool, optional If this is a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. step : number, optional Step size. vertical : bool, optional If True, the slider will be vertical caption : str, optional Heading text. References ---------- https://ant.design/components/slider/ """ super(Slider, self).__init__(caption=caption) if not start: start = [0, 0] if ranged else 0 elif isinstance(start, Iterable): start = list(start) ranged = True self._comp = self._tag.format(range=jsbool(ranged), minimum=minimum, maximum=maximum, start=start, step=step, marks={ minimum: str(minimum), maximum: str(maximum) }, vertical=jsbool(vertical))
def __init__(self, start: Optional[Union[float, Sequence[float]]] = None, ranged: bool = False, minimum: float = 0, maximum: float = 100, step: float = 1, vertical: bool = False) -> None: """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. ranged : bool, optional If this is a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. step : number, optional Step size. vertical : bool, optional If True, the slider will be vertical References ---------- https://ant.design/components/slider/ """ super().__init__() if start is None: if ranged: start = [minimum, maximum] else: start = minimum elif isinstance(start, Sequence): if len(start) > 2: raise ValueError('start cannot be more than 2 numbers') start = list(start) ranged = True self._comp = self._tag.format( range=jsbool(ranged), minimum=minimum, maximum=maximum, start=start, step=step, marks={minimum: str(minimum), maximum: str(maximum)}, vertical=jsbool(vertical) )
def __init__(self, handler, multiple=True, caption=None): """Create the widget. Note: the handler parameter may be changed in the future. Parameters ---------- handler : callable Function that accepts two arguments: a filename of type str and a stream object of type BytesIO. The user is responsible for storing the object in this function if they want it for later use. To indicate an error, return True, otherwise a return value of None or False indicate success. multiple : bool, optional If true, you can upload multiple files at once. Even with this set to true, the handler will get called once per file uploaded. caption : str, optional Heading text. """ super(Upload, self).__init__(caption=caption) self.function = handler.__name__ self._comp = self._tag.format( multiple=jsbool(multiple) )
def __init__(self, start: Union[int, Sequence[int]] = 0, minimum: int = 0, maximum: int = 100, tooltips: bool = True) -> None: """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. tooltips : bool, optional Show a popup text box. References ---------- https://refreshless.com/nouislider/events-callbacks/ """ super().__init__() if not isinstance(start, Sequence): nstart = [start] else: nstart = list(start) self._comp = self._tag.format( min=minimum, max=maximum, start=nstart, tooltips=jsbool(tooltips) )
def __init__(self, start: Union[int, Sequence[int]] = 0, minimum: int = 0, maximum: int = 100, tooltips: bool = True) -> None: """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. tooltips : bool, optional Show a popup text box. References ---------- https://refreshless.com/nouislider/events-callbacks/ """ super().__init__() if not isinstance(start, Sequence): nstart = [start] else: nstart = list(start) self._comp = self._tag.format(min=minimum, max=maximum, start=nstart, tooltips=jsbool(tooltips))
def __init__(self, labels: Optional[Sequence[str]] = None, values: Optional[Sequence[Union[str, int]]] = None, multi: bool = False, default: Optional[Union[str, int]] = None) -> None: """Create a drop down. Parameters ---------- labels : array-like, optional List of strings which will be visible to the user. values : array-like, optional List of values associated with the labels that are hidden from the user. multi : bool, optional If multiple selections are allowed. default : str or int, optional The default selected value. """ super().__init__() if values is not None and labels is not None: options = [{'value': value, 'label': str(label)} for value, label in zip(values, labels)] else: options = [] self._comp = self._tag.format( options=jdumps(options), multi=jsbool(multi), default=jdumps(default), )
def __init__(self, labels: Optional[Sequence[str]] = None, values: Optional[Sequence[Union[str, int]]] = None, multi: bool = False, default: Optional[Union[str, int]] = None) -> None: """Create a drop down. Parameters ---------- labels : array-like, optional List of strings which will be visible to the user. values : array-like, optional List of values associated with the labels that are hidden from the user. multi : bool, optional If multiple selections are allowed. default : str or int, optional The default selected value. """ super().__init__() if values is not None and labels is not None: options = [{ 'value': value, 'label': str(label) } for value, label in zip(values, labels)] else: options = [] self._comp = self._tag.format( options=jdumps(options), multi=jsbool(multi), default=jdumps(default), )
def __init__(self, start=0, minimum=0, maximum=100, tooltips=True, caption=None): """Create a slider. Parameters ---------- start : number or list with two values, optional Determines the starting value. If a list of two values are given it will be a range slider. minimum : number, optional Minimum value of the slider. maximum : number, optional Maximum value of the slider. tooltips : bool, optional Show a popup text box. caption : str, optional Heading text. References ---------- https://refreshless.com/nouislider/events-callbacks/ """ super(Nouislider, self).__init__(caption=caption) if not isinstance(start, Iterable): start = [start] else: start = list(start) self._comp = self._tag.format( min=minimum, max=maximum, start=start, tooltips=jsbool(tooltips) )
def __init__(self, labels=None, values=None, multi=False, default=None, caption=None): """Create a drop down. Parameters ---------- labels : array-like, optional List of strings which will be visible to the user. values : array-like, optional List of values associated with the labels that are hidden from the user. multi : bool, optional If multiple selections are allowed. caption : str, optional Heading text. """ super(Dropdown, self).__init__(caption=caption) if labels is None and values is None: labels = [] values = [] options = [dict(value=value, label=str(label)) for value, label in zip(values, labels)] self._comp = self._tag.format( options=jdumps(options), multi=jsbool(multi), default=jdumps(default), )
def __init__(self, initial: bool = False) -> None: """Create a toggle switch. Parameters ---------- initial : bool, optional Starting state of the switch. """ super().__init__() self._comp = self._tag.format(defaultChecked=jsbool(initial))
def __init__(self, initial: bool = False) -> None: """Create a toggle switch. Parameters ---------- initial : bool, optional Starting state of the switch. """ super().__init__() self._comp = self._tag.format( defaultChecked=jsbool(initial) )
def __init__(self, initial=False, caption=None): """Create a toggle switch. Parameters ---------- initial : bool, optional Starting state of the switch. caption : str, optional Label appearing above the widget. """ super(Switch, self).__init__(caption=caption) self._comp = self._tag.format(defaultChecked=jsbool(initial))
def __init__(self, preserve_aspect_ratio: bool = False) -> None: """Create SVG component. Parameters ---------- preserve_aspect_ratio : bool, optional If ``True`` it preserves the aspect ratio otherwise it will stretch to fill up the space available. """ super().__init__() self.preserve_aspect_ratio = preserve_aspect_ratio self._comp = self._tag.format( preserve_aspect_ratio=jsbool(self.preserve_aspect_ratio))
def __init__(self, multiple=True): """Create the widget. Note: the handler parameter may be changed in the future. Parameters ---------- multiple : bool, optional If true, you can upload multiple files at once. Even with this set to true, the handler will get called once per file uploaded. """ super().__init__() self._comp = self._tag.format(multiple=jsbool(multiple))
def __init__(self, preserve_aspect_ratio: bool = False) -> None: """Create SVG component. Parameters ---------- preserve_aspect_ratio : bool, optional If ``True`` it preserves the aspect ratio otherwise it will stretch to fill up the space available. """ super().__init__() self.preserve_aspect_ratio = preserve_aspect_ratio self._comp = self._tag.format( preserve_aspect_ratio=jsbool(self.preserve_aspect_ratio) )
def __init__(self, multiple=True): """Create the widget. Note: the handler parameter may be changed in the future. Parameters ---------- multiple : bool, optional If true, you can upload multiple files at once. Even with this set to true, the handler will get called once per file uploaded. """ super().__init__() self._comp = self._tag.format( multiple=jsbool(multiple) )