ProgressRing
Examples#
Determinate and indeterminate progress rings#
import asyncio
import flet as ft
async def main(page: ft.Page):
page.add(
ft.Text(
value="Circular progress indicator",
theme_style=ft.TextThemeStyle.HEADLINE_SMALL,
),
ft.Row(
controls=[
determinate_ring := ft.ProgressRing(
width=16, height=16, stroke_width=2
),
determinate_message := ft.Text("Wait for the completion..."),
]
),
ft.Text(
value="Indeterminate cicrular progress",
theme_style=ft.TextThemeStyle.HEADLINE_SMALL,
),
ft.Column(
horizontal_alignment=ft.CrossAxisAlignment.CENTER,
controls=[ft.ProgressRing(), ft.Text("I'm going to run for ages...")],
),
)
for i in range(0, 101):
determinate_ring.value = i * 0.01
await asyncio.sleep(0.1)
if i == 100:
determinate_message.value = "Finished!"
page.update()
ft.run(main)
Gauge with progress#
import flet as ft
def main(page: ft.Page):
page.add(
ft.Stack(
width=100,
height=100,
controls=[
ft.Container(content=ft.Text("60%"), alignment=ft.Alignment.CENTER),
ft.ProgressRing(value=0.6, width=100, height=100),
],
)
)
ft.run(main)
ProgressRing
#
Bases: ConstrainedControl
A material design circular progress indicator, which spins to indicate that the application is busy.
A control that shows progress along a circle.
animate_offset
#
animate_offset: AnimationValue | None = None
animate_opacity
#
animate_opacity: AnimationValue | None = None
animate_position
#
animate_position: AnimationValue | None = None
animate_rotation
#
animate_rotation: AnimationValue | None = None
animate_scale
#
animate_scale: AnimationValue | None = None
bgcolor
#
bgcolor: ColorValue | None = None
Color of the circular track being filled by the circular indicator.
bottom
#
bottom: Number | None = None
The distance that the child's bottom edge is inset from the bottom of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack
control, Page.overlay
list.
col
#
col: ResponsiveNumber = 12
If a parent of this control is a ResponsiveRow
,
this property is used to determine
how many virtual columns of a screen this control will span.
Can be a number or a dictionary configured to have a different value for specific
breakpoints, for example col={"sm": 6}
.
This control spans the 12 virtual columns by default.
Dimensions
Breakpoint | Dimension |
---|---|
xs | <576px |
sm | ≥576px |
md | ≥768px |
lg | ≥992px |
xl | ≥1200px |
xxl | ≥1400px |
disabled
#
disabled: bool = False
Every control has disabled
property which is False
by default - control and all
its children are enabled.
Note
The value of this property will be propagated down to all children controls recursively.
expand
#
expand_loose
#
expand_loose: bool = False
Allows the control to expand along the main axis if space is available, but does not require it to fill all available space.
More information here.
left
#
left: Number | None = None
The distance that the child's left edge is inset from the left of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack
control, Page.overlay
list.
offset
#
offset: OffsetValue | None = None
Applies a translation transformation before painting the control.
The translation is expressed as an Offset
scaled to the control's size.
So, Offset(x=0.25, y=0)
, for example, will result in a horizontal translation
of one quarter the width of this control.
Example
The following example displays container at 0, 0
top left corner of a stack as
transform applies -1 * 100, -1 * 100
(offset * control's size
) horizontal and
vertical translations to the control:
on_animation_end
#
on_animation_end: (
ControlEventHandler[ConstrainedControl] | None
) = None
Called when animation completes.
Can be used to chain multiple animations.
The data
property of the event handler argument contains the name of the animation.
More information here.
opacity
#
opacity: Number = 1.0
Defines the transparency of the control.
Value ranges from 0.0
(completely transparent) to 1.0
(completely opaque
without any transparency).
padding
#
padding: PaddingValue | None = None
The padding around the indicator track.
If None
,
ProgressIndicatorTheme.circular_track_padding
is used.
If that's is also None
and year_2023
is False
,
defaults to Padding.all(4.0)
.
Otherwise, defaults to Padding.all(0.0)
.
page
#
The page (of type Page
or PageView
) to which this control belongs to.
parent
#
parent: BaseControl | None
The direct ancestor(parent) of this control.
It defaults to None
and will only have a value when this control is mounted (added to the page tree).
The Page
control (which is the root of the tree) is an exception - it always has parent=None
.
right
#
right: Number | None = None
The distance that the child's right edge is inset from the right of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack
control, Page.overlay
list.
rotate
#
rotate: RotateValue | None = None
Transforms this control using a rotation around its center.
The value of rotate
property could be one of the following types:
number
- a rotation in clockwise radians. Full circle360°
ismath.pi * 2
radians,90°
ispi / 2
,45°
ispi / 4
, etc.Rotate
- allows to specify rotationangle
as well asalignment
- the location of rotation center.
scale
#
scale: ScaleValue | None = None
Scales this control along the 2D plane. Default scale factor is 1.0
, meaning no-scale.
Setting this property to 0.5
, for example, makes this control twice smaller, while 2.0
makes it twice larger.
Different scale multipliers can be specified for x
and y
axis, by setting
Control.scale
property to an instance of Scale
class.
Either scale
or scale_x
and scale_y
could be specified, but not all of them.
semantics_label
#
semantics_label: str | None = None
Used to identify the purpose of this progress bar for screen reading software.
semantics_value
#
semantics_value: Number | None = None
Used for determinate progress indicators to indicate how much progress has been made.
size_constraints
#
size_constraints: BoxConstraints | None = None
Defines the minimum and maximum size of the progress indicator.
If None
,
ProgressIndicatorTheme.size_constraints
is used.
If that's is also None
, defaults to a minimum width and height of 36
.
stroke_align
#
stroke_align: Number | None = None
The relative position of the stroke.
Value typically ranges be -1.0
(inside stroke) and 1.0
(outside stroke).
A value of 0 (center stroke) will center the border on the edge of the control.
If ProgressRing.year_2023
is True
, then the
default value is 0
. Otherwise, the default value is -1
.
tooltip
#
tooltip: TooltipValue | None = None
The tooltip ot show when this control is hovered over.
top
#
top: Number | None = None
The distance that the child's top edge is inset from the top of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack
control, Page.overlay
list.
track_gap
#
track_gap: Number | None = None
The gap between the active indicator and the background track.
If year_2023
is True
or Theme.use_material3
is
False
, then no track gap will be drawn.
Set track_gap
to 0
to hide this track gap.
If None
,
ProgressIndicatorTheme.track_gap
is used.
If that's is also None
, defaults to 4.0
.
value
#
value: Number | None = None
The value of this progress indicator.
A value of 0.0
means no progress and 1.0
means that progress is complete.
The value will be clamped to be in the range 0.0
- 1.0
. If None
, this
progress indicator is indeterminate, which means the indicator displays a
predetermined animation that does not indicate how much actual progress is being
made.
visible
#
visible: bool = True
Every control has visible
property which is True
by default - control is
rendered on the page. Setting visible
to False
completely prevents control (and
all its children if any) from rendering on a page canvas. Hidden controls cannot be
focused or selected with a keyboard or mouse and they do not emit any events.
year_2023
#
year_2023: bool | None = None
If this is set to False
, the ProgressRing
will use the latest Material Design 3
appearance, which was introduced in December 2023.
When True
, the ProgressRing
will use the 2023 Material Design 3 appearance.
If not set, then the
ProgressIndicatorTheme.year_2023
will be
used, which is False
by default.
If Theme.use_material3
is False
, then this property
is ignored.