Skip to content

Canvas, Charts controls docstrings #5343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0dc605a
Canvas docstrings
InesaFitsner May 28, 2025
3257fa2
CanvasResizeEvent docstrings
InesaFitsner May 28, 2025
fee1798
Arc docstrings
InesaFitsner May 28, 2025
e3073e7
Circle shape docstrings
InesaFitsner May 28, 2025
8c191a9
Color shape docstrings
InesaFitsner May 28, 2025
9a173d3
Fill shape docstrings
InesaFitsner May 28, 2025
75f8f44
Line shape docstrings
InesaFitsner May 28, 2025
96c5a0f
Oval shape docstrings
InesaFitsner May 28, 2025
f0d15e6
Path shape docstrings
InesaFitsner May 28, 2025
d1a2c59
Points shape dosctrings
InesaFitsner May 28, 2025
501dda4
Rect shape docstrings
InesaFitsner May 28, 2025
fca40e7
Shadow shape docstrings
InesaFitsner May 28, 2025
87791ca
Text shape docstrings
InesaFitsner May 28, 2025
4a4ce54
removed List from types
InesaFitsner May 28, 2025
cddc6ee
BarChart docstrings
InesaFitsner May 28, 2025
e5bf378
BarChartEvent docstrings
InesaFitsner May 28, 2025
a0098b4
BarChart docstrings
InesaFitsner May 28, 2025
cdf6a2e
BarChartRod docstrings
InesaFitsner May 28, 2025
054d67b
ChartAxis docstrings
InesaFitsner May 28, 2025
d7784df
ChartAxisLabel docstrings
InesaFitsner May 28, 2025
a5606b2
Chart docstrings
InesaFitsner May 28, 2025
c8ec63b
ChartSquarePoint, ChartCrossPoint
InesaFitsner May 28, 2025
b81adfe
ChartCirclePoint docstrings
InesaFitsner May 28, 2025
353615c
LineChart docstrings
InesaFitsner May 28, 2025
5d399c1
LineChartData, LineChartDataPoint
InesaFitsner May 29, 2025
0d1ffa7
LineChartEvent, LineChartEventSpot
InesaFitsner May 29, 2025
a1d66e7
PieChartSection docstrings
InesaFitsner May 29, 2025
2578ca7
Update pie_chart_section.py
InesaFitsner May 29, 2025
4beb6a5
PieChartEvent docstrings
InesaFitsner May 29, 2025
a4c5593
PieChart docstrings
InesaFitsner May 29, 2025
e1992d9
ScatterChart docstrings - TBD
InesaFitsner May 29, 2025
370a5e0
AdaptiveControl
InesaFitsner May 29, 2025
34b37c2
Alignment docstrings
InesaFitsner May 29, 2025
b581da1
Animation
InesaFitsner May 29, 2025
412d664
AnimationStyle
InesaFitsner May 29, 2025
0c56dc8
Blur docstrings
InesaFitsner May 29, 2025
f805b2a
BorderRadius docstrings
InesaFitsner May 29, 2025
cc6e267
Border class and image for Container docstrings
InesaFitsner May 29, 2025
3ae1a50
Border docstrings
InesaFitsner May 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions sdk/python/packages/flet/src/flet/controls/adaptive_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,46 @@

@control(kw_only=True)
class AdaptiveControl(Control):
"""
Adaptive controls are either Material design controls that have their Cupertino
analogs or container controls.
"""
adaptive: Optional[bool] = None
"""
`adaptive` property can be specified for a control in the following cases:

* A control has matching Cupertino control with similar functionality/presentation
and graphics as expected on iOS/macOS. In this case, if `adaptive` is `True`,
either Material or Cupertino control will be created depending on the target
platform.

These controls have their Cupertino analogs and `adaptive` property:
* [`AlertDialog`](https://flet.dev/docs/controls/alertdialog)
* [`AppBar`](https://flet.dev/docs/controls/appbar)
* [`Checkbox`](https://flet.dev/docs/controls/checkbox)
* [`ListTile`](https://flet.dev/docs/controls/listtile)
* [`NavigationBar`](https://flet.dev/docs/controls/navigationbar)
* [`Radio`](https://flet.dev/docs/controls/radio)
* [`Slider`](https://flet.dev/docs/controls/slider)
* [`Switch`](https://flet.dev/docs/controls/switch)

* A control has child controls. In this case `adaptive` property value is passed on
to its children that don't have their `adaptive` property set.

The following container controls have `adaptive` property:
* [`Card`](https://flet.dev/docs/controls/card)
* [`Column`](https://flet.dev/docs/controls/column)
* [`Container`](https://flet.dev/docs/controls/container)
* [`Dismissible`](https://flet.dev/docs/controls/dismissible)
* [`ExpansionPanel`](https://flet.dev/docs/controls/expansionpanel)
* [`FletApp`](https://flet.dev/docs/controls/fletapp)
* [`GestureDetector`](https://flet.dev/docs/controls/gesturedetector)
* [`GridView`](https://flet.dev/docs/controls/gridview)
* [`ListView`](https://flet.dev/docs/controls/listview)
* [`Page`](https://flet.dev/docs/controls/page)
* [`Row`](https://flet.dev/docs/controls/row)
* [`SafeArea`](https://flet.dev/docs/controls/safearea)
* [`Stack`](https://flet.dev/docs/controls/stack)
* [`Tabs`](https://flet.dev/docs/controls/tabs)
* [`View`](https://flet.dev/docs/controls/view)
"""
55 changes: 42 additions & 13 deletions sdk/python/packages/flet/src/flet/controls/alignment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass, field
from dataclasses import dataclass
from enum import Enum
from typing import Optional

Expand All @@ -19,56 +19,85 @@ class Axis(Enum):

@dataclass
class Alignment:
"""
Used to define an alignment relative to the center.
"""

x: Number
"""
Represents the horizontal distance from the center. It's value ranges between
`-1.0` and `1.0`.
"""

y: Number
"""
Represents the vertical distance from the center. It's value ranges between
`-1.0` and `1.0`.
"""

@classmethod
def bottom_center(cls) -> "Alignment":
"""
Represents the bottom center and is equivalent to `Alignment(0.0, 1.0)`.
"""
return Alignment(0, 1)

@classmethod
def bottom_left(cls) -> "Alignment":
"""
Represents the bottom left corner and is equivalent to `Alignment(-1.0, 1.0)`.
"""
return Alignment(-1, 1)

@classmethod
def bottom_right(cls) -> "Alignment":
"""
Represents the bottom right corner and is equivalent to `Alignment(1.0, 1.0)`.
"""
return Alignment(1, 1)

@classmethod
def center(cls) -> "Alignment":
"""
Represents the center and is equivalent to `Alignment(0.0, 0.0)`.
"""
return Alignment(0, 0)

@classmethod
def center_left(cls) -> "Alignment":
"""
Represents the center left and is equivalent to `Alignment(-1.0, 0.0)`.
"""
return Alignment(-1, 0)

@classmethod
def center_right(cls) -> "Alignment":
"""
Represents the center right and is equivalent to `Alignment(1.0, 0.0)`.
"""
return Alignment(1, 0)

@classmethod
def top_center(cls) -> "Alignment":
"""
Represents the top center and is equivalent to `Alignment(0.0, -1.0)`.
"""
return Alignment(0, -1)

@classmethod
def top_left(cls) -> "Alignment":
"""
Represents the top left corner and is equivalent to `Alignment(-1.0, -1.0)`.
"""
return Alignment(-1, -1)

@classmethod
def top_right(cls) -> "Alignment":
"""
Represents the top right corner and is equivalent to `Alignment(1.0, -1.0)`.
"""
return Alignment(1, -1)


# Constants
# bottom_center = Alignment(0, 1)
# bottom_left = Alignment(-1, 1)
# bottom_right = Alignment(1, 1)
# center = Alignment(0, 0)
# center_left = Alignment(-1, 0)
# center_right = Alignment(1, 0)
# top_center = Alignment(0, -1)
# top_left = Alignment(-1, -1)
# top_right = Alignment(1, -1)


# Typing
OptionalAlignment = Optional[Alignment]
Expand Down
30 changes: 30 additions & 0 deletions sdk/python/packages/flet/src/flet/controls/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,46 @@ class AnimationCurve(Enum):
@dataclass
class Animation:
duration: OptionalDurationValue = None
"""
The duration of the animation.
"""

curve: "OptionalAnimationCurve" = None
"""
The curve to use for the animation.
"""


@dataclass
class AnimationStyle:
duration: OptionalDurationValue = None
"""
The duration of the animation.

Value is of type [`DurationValue`](https://flet.dev/docs/reference/types/aliases#durationvalue).
"""

reverse_duration: OptionalDurationValue = None
"""
The duration of the reverse animation.

Value is of type [`DurationValue`](https://flet.dev/docs/reference/types/aliases#durationvalue).
"""

curve: "OptionalAnimationCurve" = None
"""
The curve to use for the animation.

Value is of type [`AnimationCurve`](https://flet.dev/docs/reference/types/animationcurve).
"""

reverse_curve: "OptionalAnimationCurve" = None
"""
The curve to use for the reverse animation.

Value is of type [`AnimationCurve`](https://flet.dev/docs/reference/types/animationcurve).
"""


AnimationValue = Union[bool, int, Animation]
OptionalAnimationValue = Optional[AnimationValue]
Expand Down
17 changes: 15 additions & 2 deletions sdk/python/packages/flet/src/flet/controls/blur.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum
from typing import Optional, Tuple, Union
from typing import Optional, Union

from flet.controls.types import Number

Expand All @@ -23,10 +23,23 @@ class BlurTileMode(Enum):
@dataclass
class Blur:
sigma_x: Number
"""
Horizontal sigma.
"""

sigma_y: Number
"""
Vertical sigma.
"""

tile_mode: Optional[BlurTileMode] = None
"""
The tile mode for the blur.

Value is of type [`BlurTileMode`](https://flet.dev/docs/reference/types/blurtilemode).
"""


BlurValue = Union[Number, Tuple[Number, Number], Blur]
BlurValue = Union[Number, tuple[Number, Number], Blur]
OptionalBlurValue = Optional[BlurValue]
OptionalBlurTileMode = Optional[BlurTileMode]
41 changes: 41 additions & 0 deletions sdk/python/packages/flet/src/flet/controls/border.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,46 @@ class BorderSide:

@dataclass
class Border:
"""
A border comprised of four sides: top, right, bottom, left.

Each side of the border is described by an instance of [`BorderSide`](https://flet.dev/docs/reference/types/borderside)
class.

Usage example:
```python
container_1.border = ft.Border.all(10, ft.Colors.PINK_600)
container_1.border = ft.Border.only(bottom=ft.BorderSide(1, "black"))
```
"""

top: "OptionalBorderSide" = None
"""
Top side of the border.
"""

right: "OptionalBorderSide" = None
"""
Right side of the border.
"""

bottom: "OptionalBorderSide" = None
"""
Bottom side of the border.
"""

left: "OptionalBorderSide" = None
"""
Left side of the border.
"""

@classmethod
def all(
cls, width: OptionalNumber = None, color: OptionalColorValue = None
) -> "Border":
"""
Sets the same border for all 4 sides of the rectangle.
"""
bs = BorderSide(width or 1.0, color or Colors.BLACK)
return Border(left=bs, top=bs, right=bs, bottom=bs)

Expand All @@ -55,6 +86,10 @@ def symmetric(
vertical: "OptionalBorderSide" = None,
horizontal: "OptionalBorderSide" = None,
) -> "Border":
"""
Sets `vertical` border for top and bottom sides and `horizontal` for the left
and right sides of the rectangle.
"""
return Border(left=horizontal, top=vertical, right=horizontal, bottom=vertical)

@classmethod
Expand All @@ -66,6 +101,9 @@ def only(
right: "OptionalBorderSide" = None,
bottom: "OptionalBorderSide" = None,
) -> "Border":
"""
Sets different borders for each side of the rectangle.
"""
return Border(left=left, top=top, right=right, bottom=bottom)


Expand Down Expand Up @@ -109,6 +147,9 @@ def only(

# Typings
OptionalBorder = Optional[Border]
"""
OptionalBorder type description
"""
OptionalBorderSide = Optional[BorderSide]
OptionalBorderSideStrokeAlign = Optional[BorderSideStrokeAlign]
BorderSideStrokeAlignValue = Union[BorderSideStrokeAlign, Number]
Expand Down
33 changes: 33 additions & 0 deletions sdk/python/packages/flet/src/flet/controls/border_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,54 @@
@dataclasses.dataclass
class BorderRadius:
top_left: Number
"""
Radius of the top left border corner.
"""

top_right: Number
"""
Radius of the top right border corner.
"""

bottom_left: Number
"""
Radius of the bottom left border corner.
"""

bottom_right: Number
"""
Radius of the bottom right border corner.
"""

@classmethod
def all(cls, value: Number) -> "BorderRadius":
"""
Sets the same border radius of `value` for all 4 corners of the rectangle.
"""
return BorderRadius(
top_left=value, top_right=value, bottom_left=value, bottom_right=value
)

@classmethod
def horizontal(cls, *, left: Number = 0, right: Number = 0) -> "BorderRadius":
"""
Sets the border radius horizontally for the left and right corners of the
rectangle.

Both `left` and `right` default to `0`.
"""
return BorderRadius(
top_left=left, top_right=right, bottom_left=left, bottom_right=right
)

@classmethod
def vertical(cls, *, top: Number = 0, bottom: Number = 0) -> "BorderRadius":
"""
Sets the border radius vertically for the top and bottom corners of the
rectangle.

Both `top` and `bottom` default to `0`.
"""
return BorderRadius(
top_left=top, top_right=top, bottom_left=bottom, bottom_right=bottom
)
Expand All @@ -49,6 +79,9 @@ def only(
bottom_left: Number = 0,
bottom_right: Number = 0,
) -> "BorderRadius":
"""
Sets different border radius for each corner of the rectangle.
"""
return BorderRadius(
top_left=top_left,
top_right=top_right,
Expand Down
Loading