Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
10a2b61
added comments for page, container, tooltip
InesaFitsner Nov 28, 2022
fef2fa6
comments for view, row
InesaFitsner Nov 28, 2022
3a1df36
comments for column
InesaFitsner Nov 28, 2022
88d5f26
updated example
InesaFitsner Nov 28, 2022
cfddebf
comments
InesaFitsner Nov 28, 2022
7f74f5f
Update stack.py
InesaFitsner Nov 28, 2022
be7d788
Update list_view.py
InesaFitsner Nov 29, 2022
8e5753e
Update list_tile.py
InesaFitsner Nov 29, 2022
280a21b
Update grid_view.py
InesaFitsner Nov 29, 2022
ebec45f
Update responsive_row.py
InesaFitsner Nov 29, 2022
a8fd4d0
Update tabs.py
InesaFitsner Nov 29, 2022
15ab3b4
Update card.py
InesaFitsner Nov 29, 2022
cd04a38
Update divider.py
InesaFitsner Nov 29, 2022
36280ce
Update vertical_divider.py
InesaFitsner Dec 5, 2022
a141589
Update app_bar.py
InesaFitsner Dec 5, 2022
09e96bd
Update navigation_rail.py
InesaFitsner Dec 5, 2022
fca1a9d
navigation_rail and navigation_bar
InesaFitsner Dec 5, 2022
a74e5b0
Update text.py
InesaFitsner Dec 5, 2022
7a6a947
Update icon.py
InesaFitsner Dec 5, 2022
7580523
Update image.py
InesaFitsner Dec 5, 2022
4e1babc
Update markdown.py
InesaFitsner Dec 5, 2022
9c739ce
Update circle_avatar.py
InesaFitsner Dec 5, 2022
9ad97cb
Update progress_bar.py
InesaFitsner Dec 6, 2022
04e6852
Update progress_ring.py
InesaFitsner Dec 6, 2022
e2a76e1
Update elevated_button.py
InesaFitsner Dec 6, 2022
58b8a44
Update filled_button.py
InesaFitsner Dec 6, 2022
ddcb073
Update filled_tonal_button.py
InesaFitsner Dec 6, 2022
be6829b
Update floating_action_button.py
InesaFitsner Dec 6, 2022
a448d52
Update icon_button.py
InesaFitsner Dec 6, 2022
59c1bbd
Update outlined_button.py
InesaFitsner Dec 6, 2022
2be9194
Update popup_menu_button.py
InesaFitsner Dec 6, 2022
48736a2
Update text_button.py
InesaFitsner Dec 6, 2022
05caef7
Update checkbox.py
InesaFitsner Dec 6, 2022
900390c
Update dropdown.py
InesaFitsner Dec 6, 2022
cf333e6
Radio and RadioGroup comments
InesaFitsner Dec 6, 2022
5c73329
Update slider.py
InesaFitsner Dec 6, 2022
a7cd5d6
Update switch.py
InesaFitsner Dec 6, 2022
e59efd8
Update textfield.py
InesaFitsner Dec 6, 2022
f79eb41
Update alert_dialog.py
InesaFitsner Dec 7, 2022
a01e228
Update banner.py
InesaFitsner Dec 7, 2022
a45a68b
Update bottom_sheet.py
InesaFitsner Dec 7, 2022
c00a607
Update snack_bar.py
InesaFitsner Dec 7, 2022
5333ece
Update matplotlib_chart.py
InesaFitsner Dec 7, 2022
4b7d0c5
Update plotly_chart.py
InesaFitsner Dec 7, 2022
24127cb
Update animated_switcher.py
InesaFitsner Dec 7, 2022
9d66350
Update audio.py
InesaFitsner Dec 7, 2022
e52a6bd
Update draggable.py
InesaFitsner Dec 7, 2022
2bd6c1a
Update drag_target.py
InesaFitsner Dec 7, 2022
5c944e0
Update file_picker.py
InesaFitsner Dec 7, 2022
bdf4eea
Update gesture_detector.py
InesaFitsner Dec 7, 2022
e86f58e
Update haptic_feedback.py
InesaFitsner Dec 7, 2022
c098e17
Update semantics.py
InesaFitsner Dec 7, 2022
68e6971
Update shader_mask.py
InesaFitsner Dec 7, 2022
bb35a8e
Update shake_detector.py
InesaFitsner Dec 7, 2022
a52a9e9
Update window_drag_area.py
InesaFitsner Dec 7, 2022
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
51 changes: 51 additions & 0 deletions sdk/python/flet/alert_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,57 @@


class AlertDialog(Control):
"""
An alert dialog informs the user about situations that require acknowledgement. An alert dialog has an optional title and an optional list of actions. The title is displayed above the content and the actions are displayed below the content.

Example:
```
import flet as ft

def main(page: ft.Page):
page.title = "AlertDialog examples"

dlg = ft.AlertDialog(
title=ft.Text("Hello, you!"), on_dismiss=lambda e: print("Dialog dismissed!")
)

def close_dlg(e):
dlg_modal.open = False
page.update()

dlg_modal = ft.AlertDialog(
modal=True,
title=ft.Text("Please confirm"),
content=ft.Text("Do you really want to delete all those files?"),
actions=[
ft.TextButton("Yes", on_click=close_dlg),
ft.TextButton("No", on_click=close_dlg),
],
actions_alignment=ft.MainAxisAlignment.END,
on_dismiss=lambda e: print("Modal dialog dismissed!"),
)

def open_dlg(e):
page.dialog = dlg
dlg.open = True
page.update()

def open_dlg_modal(e):
page.dialog = dlg_modal
dlg_modal.open = True
page.update()

page.add(
ft.ElevatedButton("Open dialog", on_click=open_dlg),
ft.ElevatedButton("Open modal dialog", on_click=open_dlg_modal),
)

ft.app(target=main)
```
-----

Online docs: https://flet.dev/docs/controls/alertdialog
"""
def __init__(
self,
ref: Optional[Ref] = None,
Expand Down
48 changes: 48 additions & 0 deletions sdk/python/flet/animated_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,54 @@ class AnimatedSwitcherTransition(Enum):


class AnimatedSwitcher(ConstrainedControl):
"""
A control that by default does a cross-fade between a new control and the control previously set on the AnimatedSwitcher as a `content`.

Example:
```
import flet as ft

def main(page: ft.Page):

c1 = ft.Container(
ft.Text("Hello!", style=ft.TextThemeStyle.HEADLINE_MEDIUM),
alignment=ft.alignment.center,
width=200,
height=200,
bgcolor=ft.colors.GREEN,
)
c2 = ft.Container(
ft.Text("Bye!", size=50),
alignment=ft.alignment.center,
width=200,
height=200,
bgcolor=ft.colors.YELLOW,
)
c = ft.AnimatedSwitcher(
content=c1,
transition=ft.AnimatedSwitcherTransition.SCALE,
duration=500,
reverse_duration=100,
switch_in_curve=ft.AnimationCurve.BOUNCE_OUT,
switch_out_curve=ft.AnimationCurve.BOUNCE_IN,
)

def animate(e):
c.content = c2 if c.content == c1 else c1
c.update()

page.add(
c,
ft.ElevatedButton("Animate!", on_click=animate),
)

ft.app(target=main)
```

-----

Online docs: https://flet.dev/docs/controls/animatedswitcher
"""
def __init__(
self,
content: Optional[Control] = None,
Expand Down
47 changes: 47 additions & 0 deletions sdk/python/flet/app_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,48 @@


class AppBar(Control):
"""
A material design app bar.

Example:
```
import flet as ft

def main(page: ft.Page):
def check_item_clicked(e):
e.control.checked = not e.control.checked
page.update()

page.appbar = ft.AppBar(
leading=ft.Icon(ft.icons.PALETTE),
leading_width=40,
title=ft.Text("AppBar Example"),
center_title=False,
bgcolor=ft.colors.SURFACE_VARIANT,
actions=[
ft.IconButton(ft.icons.WB_SUNNY_OUTLINED),
ft.IconButton(ft.icons.FILTER_3),
ft.PopupMenuButton(
items=[
ft.PopupMenuItem(text="Item 1"),
ft.PopupMenuItem(), # divider
ft.PopupMenuItem(
text="Checked item", checked=False, on_click=check_item_clicked
),
]
),
],
)
page.add(ft.Text("Body!"))

ft.app(target=main)

```

-----

Online docs: https://flet.dev/docs/controls/appbar
"""
def __init__(
self,
ref: Optional[Ref] = None,
Expand Down Expand Up @@ -63,6 +105,11 @@ def leading(self) -> Optional[Control]:
@leading.setter
@beartype
def leading(self, value: Optional[Control]):
"""
A Control to display before the toolbar's title.

Typically the leading control is an Icon or an IconButton.
"""
self.__leading = value

# leading_width
Expand Down
26 changes: 26 additions & 0 deletions sdk/python/flet/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ class AudioMethodResults:


class Audio(Control):
"""
A control to simultaneously play multiple audio files. Works on macOS, Linux, Windows, iOS, Android and web. Based on audioplayers Flutter widget (https://pub.dev/packages/audioplayers).

Audio control is non-visual and should be added to `page.overlay` list.

Example:
```
import flet as ft

def main(page: ft.Page):
audio1 = ft.Audio(
src="https://luan.xyz/files/audio/ambient_c_motion.mp3", autoplay=True
)
page.overlay.append(audio1)
page.add(
ft.Text("This is an app with background audio."),
ft.ElevatedButton("Stop playing", on_click=lambda _: audio1.pause()),
)

ft.app(target=main)
```

-----

Online docs: https://flet.dev/docs/controls/audio
"""
def __init__(
self,
src: Optional[str] = None,
Expand Down
40 changes: 40 additions & 0 deletions sdk/python/flet/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,46 @@


class Banner(Control):
"""
A banner displays an important, succinct message, and provides actions for users to address (or dismiss the banner). A user action is required for it to be dismissed.

Banners are displayed at the top of the screen, below a top app bar. They are persistent and non-modal, allowing the user to either ignore them or interact with them at any time.

Example:
```
import flet as ft

def main(page):
def close_banner(e):
page.banner.open = False
page.update()

page.banner = ft.Banner(
bgcolor=ft.colors.AMBER_100,
leading=ft.Icon(ft.icons.WARNING_AMBER_ROUNDED, color=ft.colors.AMBER, size=40),
content=ft.Text(
"Oops, there were some errors while trying to delete the file. What would you like me to do?"
),
actions=[
ft.TextButton("Retry", on_click=close_banner),
ft.TextButton("Ignore", on_click=close_banner),
ft.TextButton("Cancel", on_click=close_banner),
],
)

def show_banner_click(e):
page.banner.open = True
page.update()

page.add(ft.ElevatedButton("Show Banner", on_click=show_banner_click))

ft.app(target=main)
```

-----

Online docs: https://flet.dev/docs/controls/banner
"""
def __init__(
self,
ref: Optional[Ref] = None,
Expand Down
43 changes: 43 additions & 0 deletions sdk/python/flet/bottom_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,49 @@


class BottomSheet(Control):
"""
A modal bottom sheet is an alternative to a menu or a dialog and prevents the user from interacting with the rest of the app.

Example:
```
import flet as ft

def main(page: ft.Page):
def bs_dismissed(e):
print("Dismissed!")

def show_bs(e):
bs.open = True
bs.update()

def close_bs(e):
bs.open = False
bs.update()

bs = ft.BottomSheet(
ft.Container(
ft.Column(
[
ft.Text("This is sheet's content!"),
ft.ElevatedButton("Close bottom sheet", on_click=close_bs),
],
tight=True,
),
padding=10,
),
open=True,
on_dismiss=bs_dismissed,
)
page.overlay.append(bs)
page.add(ft.ElevatedButton("Display bottom sheet", on_click=show_bs))

ft.app(target=main)
```

-----

Online docs: https://flet.dev/docs/controls/bottomsheet
"""
def __init__(
self,
content: Optional[Control] = None,
Expand Down
42 changes: 42 additions & 0 deletions sdk/python/flet/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,48 @@


class Card(ConstrainedControl):
"""
A material design card: a panel with slightly rounded corners and an elevation shadow.

Example:
```
import flet as ft

def main(page):
page.title = "Card Example"
page.add(
ft.Card(
content=ft.Container(
content=ft.Column(
[
ft.ListTile(
leading=ft.Icon(ft.icons.ALBUM),
title=ft.Text("The Enchanted Nightingale"),
subtitle=ft.Text(
"Music by Julie Gable. Lyrics by Sidney Stein."
),
),
ft.Row(
[ft.TextButton("Buy tickets"), ft.TextButton("Listen")],
alignment=ft.MainAxisAlignment.END,
),
]
),
width=400,
padding=10,
)
)
)

ft.app(target=main)

```

-----

Online docs: https://flet.dev/docs/controls/card
"""

def __init__(
self,
content: Optional[Control] = None,
Expand Down
32 changes: 32 additions & 0 deletions sdk/python/flet/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,38 @@


class Checkbox(ConstrainedControl):
"""
Checkbox allows to select one or more items from a group, or switch between two mutually exclusive options (checked or unchecked, on or off).

Example:
```
import flet as ft

def main(page):
def button_clicked(e):
t.value = (
f"Checkboxes values are: {c1.value}, {c2.value}, {c3.value}, {c4.value}, {c5.value}."
)
page.update()

t = ft.Text()
c1 = ft.Checkbox(label="Unchecked by default checkbox", value=False)
c2 = ft.Checkbox(label="Undefined by default tristate checkbox", tristate=True)
c3 = ft.Checkbox(label="Checked by default checkbox", value=True)
c4 = ft.Checkbox(label="Disabled checkbox", disabled=True)
c5 = ft.Checkbox(
label="Checkbox with rendered label_position='left'", label_position=ft.LabelPosition.LEFT
)
b = ft.ElevatedButton(text="Submit", on_click=button_clicked)
page.add(c1, c2, c3, c4, c5, b, t)

ft.app(target=main)
```

-----

Online docs: https://flet.dev/docs/controls/checkbox
"""
def __init__(
self,
ref: Optional[Ref] = None,
Expand Down
Loading