progress.py

No documentation

class ProgressBar

Description

A progress bar widget that displays a value as a filled bar.
Supports horizontal/vertical orientation and a 'soundpad' segmented style.

Attributes
_properties: Dict[str, Dict[str, Any]] = {**UIElement._properties, 'min_val': {'name': 'minimum value', 'key': 'min_val', 'type': float, 'editable': True, 'description': 'Minimum value (0% progress).'}, 'max_val': {'name': 'maximum value', 'key': 'max_val', 'type': float, 'editable': True, 'description': 'Maximum value (100% progress).'}, 'value': {'name': 'current value', 'key': 'value', 'type': float, 'editable': True, 'description': 'Current progress value.'}, 'orientation': {'name': 'orientation', 'key': 'orientation', 'type': str, 'editable': True, 'description': '"horizontal" or "vertical".', 'options': ['horizontal', 'vertical']}, 'style': {'name': 'style', 'key': 'style', 'type': str, 'editable': True, 'description': '"default" or "soundpad".', 'options': ['default', 'soundpad']}, 'draw_value': {'name': 'draw value', 'key': 'draw_value', 'type': bool, 'editable': True, 'description': 'Show percentage text inside the bar.'}}
Methods
def __init__(self: Any, x: int, y: int, width: int, height: int, min_val: float = 0, max_val: float = 100, value: float = 0, pivot: Tuple[float, float] = (0, 0), theme: Optional[ThemeType] = None, orientation: Literal['vertical', 'horizontal'] = 'horizontal', element_id: Optional[str] = None, style: str = 'default', **kwargs: dict) -> None
Initialize a progress bar.

Args:
   x, y: Position (before anchor).
   width, height: Dimensions.
   min_val: Minimum value (0%).
   max_val: Maximum value (100%).
   value: Current value.
   pivot: Anchor point.
   theme: Theme to apply.
   orientation: 'horizontal' or 'vertical'.
   element_id: Custom ID.
   style: 'default' or 'soundpad' (segmented with gradient colors).
   **kwargs: Additional parameters:
       draw_value (bool): Show percentage text.
       font_size (int): Font size for text.
       font_draw (str): Font name for text.
       segment_count (int): Number of segments for soundpad style.
       segment_gap (int): Gap between segments.
def _get_init_args(self: Any) -> Dict[str, Any]
Return constructor arguments for restarting.
def set_background_color(self: Any, color: Tuple[int, int, int]) -> None
Set the background (empty part) color.
def set_foreground_color(self: Any, color: Tuple[int, int, int]) -> None
Set the foreground (filled part) color.
def set_font_color(self: Any, color: Tuple[int, int, int]) -> None
Set the color of the percentage text.
def set_font(self: Any, font_name: str, font_size: int) -> None
Set a custom font for the percentage text.
def set_border_color(self: Any, color: Tuple[int, int, int]) -> None
Set the border color (only used in default style).
def update_theme(self: Any, theme_type: ThemeType) -> None
Apply a new theme to the progress bar.
def set_value(self: Any, value: float) -> None
Update the current progress value (clamped to min/max).
def set_max_value(self: Any, value: float) -> None
Update the maximum progress value (clamped to min/max).
def set_min_value(self: Any, value: float) -> None
Update the minimum progress value (clamped to min/max).
def get_percentage(self: Any) -> float
Return the current progress as a percentage (0-100).
def _get_soundpad_color(self: Any, t: float) -> Tuple[int, int, int]
Get a gradient color for soundpad style (t in [0,1]).
def render(self: Any, renderer: Renderer) -> None
Render the progress bar.
Back to Ui Module