duck.html.components.progressbar

Progress bar component.

Module Contents

Classes

ProgressBar

iOS-style linear progress bar with JavaScript and Python update helpers.

Data

PROGRESS_BAR_SCRIPT

API

duck.html.components.progressbar.PROGRESS_BAR_SCRIPT = <Multiline-String>
class duck.html.components.progressbar.ProgressBar(element: Optional[str] = None, properties: Optional[Dict[str, str]] = None, props: Optional[Dict[str, str]] = None, style: Optional[Dict[str, str]] = None, inner_html: Optional[Union[str, str, float]] = None, children: Optional[List[duck.html.components.HtmlComponent]] = None, **kwargs)[source]

Bases: duck.html.components.container.Container

iOS-style linear progress bar with JavaScript and Python update helpers.

Colors are themeable: they default to Theme.current.progress_color and Theme.current.progress_track_color when the active Theme.current defines them, and can always be overridden per-instance via set_progress_color/set_track_color.

Initialization

Initialize an HTML component.

Parameters:
  • element – The HTML element tag name (e.g., textarea, input, button). Can be None, but make sure element is returned by get_element method.

  • accept_inner_html – Whether the HTML component accepts an inner body (e.g., inner-body-here).

  • inner_html – Inner html to add to the HTML component. Defaults to None.

  • properties – Dictionary for properties to initialize the component with.

  • props – Just same as properties argument (added for simplicity).

  • style – Dictionary for style to initialize the component with.

  • event_handlers – Events to automatically bind. Each dictionary maps an event name to its handler and may include additional keyword arguments forwarded to bind(), e.g. event_handlers=[{"click": on_button_click, **extra_kwargs}].

  • **kwargs – Extra keyword arguments

Raises:

HtmlComponentError – If ‘element’ is not a string or ‘inner_html’ is set but ‘accept_inner_html’ is False.

FADE_MASK

‘linear-gradient(to right, black 0%, black 88%, transparent 100%)’

FADE_TIP

True

FILL_COLOR

‘getattr(…)’

FILL_TRANSITION

‘transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94)’

TRACK_COLOR

‘getattr(…)’

TRACK_HEIGHT

‘3px’

on_create() None[source]

Initialize and compose the progress bar.

set_fade_tip(enabled: bool) None[source]

Toggle the soft fade at the leading edge of the progress fill.

Parameters:

enabled – Whether the fade should be applied.

set_progress_color(color: str) None[source]

Set the filled progress indicator color.

Parameters:

color – CSS color value.

set_track_color(color: str) None[source]

Set the progress track/background color.

Parameters:

color – CSS color value.

update_progress(progress: int) None[source]

Update the progress bar from Python.

Parameters:

progress – Progress percentage between 0 and 100.

Raises:
  • TypeError – If progress is not an integer.

  • ValueError – If progress is outside 0 to 100.