The progress bar is a simple widget for showing a percentage progress for task completion.
import toga progress = toga.ProgressBar(max=100, value=1) # Update progress progress.value = 10
A progress bar can be in one of four visual states, determined by its
max properties, and with the
start() method will make the progress bar enter running mode, and calling
stop() will exit running mode.
See the table below:
indeterminate (continuous animation)
show percentage and busy animation
If a progress bar is indeterminate, it is communicating that it has no exact percentage to report, but that work is still begin done. It may communicate this by continuously pulsing back and forth, for example.
A second type of animation occurs when a percentage is displayed and the application wants to signal that progress is still “busy”. Such an animation might involve gradually altering a lighting gradient on the progress bar.
Note: Not every platform may support these animations.
ProgressBar state examples:
# use indeterminate mode progress.max = None print(progress.is_determinate) # => False progress.start() print(progress.is_running) # => True # show percentage and busy animation (if supported) progress.max = 100 print(progress.is_determinate) # => True # signal that no work is begin done with the disabled state progress.max = None print(progress.is_determinate) # => False progress.stop() print(progress.is_running) # => False
- class toga.widgets.progressbar.ProgressBar(id=None, style=None, max=1, value=0, running=False, factory=None)#
id (str) – An identifier for this widget.
Style) – An optional style object. If no style is provided then a new one will be created for the widget.
max (float) – The maximum value of the progressbar.
value (float) – To define the current progress of the progressbar.
running (bool) – Set the initial running mode.
- MIN_WIDTH = 100#
Add the provided widgets as children of this widget.
If a node already has a different parent, it will be moved over. This does nothing if a node already is a child of this node.
ValueErrorif this widget cannot have children.
children – The widgets to add as children of this widget.
- property app#
The App to which this widget belongs.
When setting the app for a widget, all children of this widget will be recursively assigned to the same app.
ValueErrorif the widget is already associated with another app.
- property can_have_children#
Determine if the node can have children.
This does not resolve whether there actually are any children; it only confirms whether children are theoretically allowed.
- property children#
The children of this node. This always returns a list, even if the node is a leaf and cannot have children.
A list of the children for this widget.
- property enabled#
Is the widget currently enabled? i.e., can the user interact with the widget?
Set this widget to have the current input focus.
- property id#
The node identifier. This id can be used to target styling directives.
- insert(index, child)#
Insert a widget as a child of this widget.
If the node already has a parent, ownership of the widget will be transferred.
ValueErrorif this node cannot have children.
index – The position in the list of children where the new widget should be added.
child – The child to insert as a child of this node.
- property is_determinate#
Determinate progress bars have a numeric
maxvalue (not None).
True if this progress bar is determinate (
maxis not None) False if
- property is_running#
stop()to change the running state.
True if this progress bar is running False otherwise
- property max#
The maximum value of the progressbar.
The maximum value as a
- property parent#
The parent of this node.
The parent of this node. Returns None if this node is the root node.
Refresh the layout and appearance of the tree this node is contained in.
Remove the provided widgets as children of this node.
This does nothing if a given node is not a child of this node.
ValueErrorif this node is a leaf, and cannot have children.
children – The child nodes to remove.
- property root#
The root of the tree containing this node.
The root node. Returns self if this node is the root node.
Starting this progress bar puts it into running mode.
Stop this progress bar (if not already stopped).
- property tab_index#
The position of the widget in the focus chain for the window.
- property value#
Returns: The current value as a
- property window#
The window to which this widget belongs.
When setting the window for a widget, all children of this widget will be recursively assigned to the same window.