Skip to content

Commit 2d17df2

Browse files
Control gallery 0.24 (#168)
* Update 01_safearea_example.py * Update 01_menubar_example.py * Fix checkbox tooltip * updated flet version * fixed Column example async warnings * Update 03_animate_container.py * Update 01_dismissible_example.py * Update 02_draggable_divider.py * Update 01_expansionpanellist_example.py * Update 01_listtile_examples.py * Update 01_auto_scrolling_listview.py * row examples * Update 02_draggable_verticaldivider.py * Update 01_bottomappbar_example.py * Update 01_navigationbar_example.py * Update 01_navigationbar_example.py * Update 01_menubar_example.py * Update 01_navigationbar_example.py * Update 05_free-hand_drawing_tool.py * Update 01_circleavatar_example.py * markdown examples * progressbar, progressring * fixed Text example with RobotoSlab font * Update 04_text_with_variable_properties.py * Update 01_cupertino_action_sheet_example.py * Update 01_cupertino_dialog_action_example.py * Update 03_elevatedbutton_with_click_event.py * Update 06_elevatedbutton_style.py * Update 02_iconbutton_with_click_event.py * Update 01_menuitembutton_example.py * Update 03_outlinedbutton_with_click_event.py * Update 01_popupmenubutton_example.py * Update 01_submenubutton_example.py * Update 03_textbutton_with_click_event.py * checkbox examples * chip examples * Create 09_text_with_tooltip_with_a_custom_decoration.py * Update 01_cupertino_radio_example.py * CupertinoSwitch and CupertinoSlider examples * Update 01_cupertino_textfield_example.py * Dropdown examples * radio examples * Update 03_slider_with_change_event.py * Update 01_basic_switches.py * TextField examples * removed Tooltip from Utilities * Update 01_basic_and_modal_dialogs.py * Update 01_banner_with_leading_icon_and_actions.py * bottomsheet example * Update 01_cupertino_action_sheet_example.py * Update 01_cupertino_alert_dialog_example.py * CupertinoBottomSheet examples * Update 01_cupertino_date_picker_example.py * CupertinoPicker, CupertinoTimePicker * Update 01_date_picker_example.py * Update 01_snackbar_with_dynamic_message.py * Update 01_time_picker_example.py * chart examples * Update 01_animatedswitcher_example.py * Update 01_autoplay_audio.py * Update 01_drag_and_drop_colors.py * Update 01_pick_multiple_files.py * Update 01_draggable_containers.py * ShaderMask * color examples * Update requirements.txt --------- Co-authored-by: Feodor Fitsner <[email protected]>
1 parent 045c48b commit 2d17df2

File tree

97 files changed

+1009
-1062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1009
-1062
lines changed

python/apps/controls-gallery/examples/animations/animated_switcher/01_animatedswitcher_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def example():
2727
switch_out_curve=ft.AnimationCurve.BOUNCE_IN,
2828
)
2929

30-
async def animate(e):
30+
def animate(e):
3131
c.content = c2 if c.content == c1 else c1
32-
await c.update_async()
32+
c.update()
3333

3434
return ft.Column(controls=[c, ft.ElevatedButton("Animate!", on_click=animate)])

python/apps/controls-gallery/examples/buttons/cupertinoactionsheetaction/01_cupertino_action_sheet_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
def example():
77

88
def show_cupertino_action_sheet(e):
9-
e.control.page.show_bottom_sheet(ft.CupertinoBottomSheet(action_sheet))
9+
e.control.page.open(bottom_sheet)
1010

1111
def close_cupertino_action_sheet(e):
12-
e.control.page.close_bottom_sheet()
12+
e.control.page.close(bottom_sheet)
1313

1414
action_sheet = ft.CupertinoActionSheet(
1515
title=ft.Text("Title"),
@@ -36,6 +36,8 @@ def close_cupertino_action_sheet(e):
3636
],
3737
)
3838

39+
bottom_sheet = ft.CupertinoBottomSheet(action_sheet)
40+
3941
return ft.OutlinedButton(
4042
"Open CupertinoBottomSheet containing CupertinoActionSheet",
4143
on_click=show_cupertino_action_sheet,

python/apps/controls-gallery/examples/buttons/cupertinodialogaction/01_cupertino_dialog_action_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
def example():
7-
async def dismiss_dialog(e):
7+
def dismiss_dialog(e):
88
cupertino_alert_dialog.open = False
9-
await e.control.page.update_async()
9+
e.control.page.update()
1010

1111
cupertino_alert_dialog = ft.CupertinoAlertDialog(
1212
title=ft.Text("Cupertino Alert Dialog"),
@@ -20,7 +20,7 @@ async def dismiss_dialog(e):
2020
)
2121

2222
def open_dlg(e):
23-
e.control.page.dialog = cupertino_alert_dialog
23+
e.control.page.overlay.append(cupertino_alert_dialog)
2424
cupertino_alert_dialog.open = True
2525
e.control.page.update()
2626

python/apps/controls-gallery/examples/buttons/elevatedbutton/03_elevatedbutton_with_click_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55

66
def example():
7-
async def button_clicked(e):
7+
def button_clicked(e):
88
b.data += 1
99
t.value = f"Button clicked {b.data} time(s)"
10-
await t.update_async()
10+
t.update()
1111

1212
b = ft.ElevatedButton("Button with 'click' event", on_click=button_clicked, data=0)
1313
t = ft.Text()
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
import flet as ft
22

3-
name = "ElevatedButton with style attributes configured for different MaterialState values"
3+
name = (
4+
"ElevatedButton with style attributes configured for different ControlState values"
5+
)
6+
47

58
def example():
6-
9+
710
return ft.ElevatedButton(
8-
"Styled button 1",
9-
style=ft.ButtonStyle(
10-
color={
11-
ft.MaterialState.HOVERED: ft.colors.WHITE,
12-
ft.MaterialState.FOCUSED: ft.colors.BLUE,
13-
ft.MaterialState.DEFAULT: ft.colors.BLACK,
14-
},
15-
bgcolor={ft.MaterialState.FOCUSED: ft.colors.PINK_200, "": ft.colors.YELLOW},
16-
padding={ft.MaterialState.HOVERED: 20},
17-
overlay_color=ft.colors.TRANSPARENT,
18-
elevation={"pressed": 0, "": 1},
19-
animation_duration=500,
20-
side={
21-
ft.MaterialState.DEFAULT: ft.BorderSide(1, ft.colors.BLUE),
22-
ft.MaterialState.HOVERED: ft.BorderSide(2, ft.colors.BLUE),
23-
},
24-
shape={
25-
ft.MaterialState.HOVERED: ft.RoundedRectangleBorder(radius=20),
26-
ft.MaterialState.DEFAULT: ft.RoundedRectangleBorder(radius=2),
27-
},
28-
),
29-
)
11+
"Styled button 1",
12+
style=ft.ButtonStyle(
13+
color={
14+
ft.ControlState.HOVERED: ft.colors.WHITE,
15+
ft.ControlState.FOCUSED: ft.colors.BLUE,
16+
ft.ControlState.DEFAULT: ft.colors.BLACK,
17+
},
18+
bgcolor={ft.ControlState.FOCUSED: ft.colors.PINK_200, "": ft.colors.YELLOW},
19+
padding={ft.ControlState.HOVERED: 20},
20+
overlay_color=ft.colors.TRANSPARENT,
21+
elevation={"pressed": 0, "": 1},
22+
animation_duration=500,
23+
side={
24+
ft.ControlState.DEFAULT: ft.BorderSide(1, ft.colors.BLUE),
25+
ft.ControlState.HOVERED: ft.BorderSide(2, ft.colors.BLUE),
26+
},
27+
shape={
28+
ft.ControlState.HOVERED: ft.RoundedRectangleBorder(radius=20),
29+
ft.ControlState.DEFAULT: ft.RoundedRectangleBorder(radius=2),
30+
},
31+
),
32+
)

python/apps/controls-gallery/examples/buttons/iconbutton/02_iconbutton_with_click_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55

66
def example():
7-
async def button_clicked(e):
7+
def button_clicked(e):
88
b.data += 1
99
t.value = f"Button clicked {b.data} time(s)"
10-
await t.update_async()
10+
t.update()
1111

1212
b = ft.IconButton(
1313
icon=ft.icons.PLAY_CIRCLE_FILL_OUTLINED, on_click=button_clicked, data=0

python/apps/controls-gallery/examples/buttons/menuitembutton/01_menuitembutton_example.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def example():
1010
alignment=ft.alignment.top_left,
1111
bgcolor=ft.colors.RED_100,
1212
mouse_cursor={
13-
ft.MaterialState.HOVERED: ft.MouseCursor.WAIT,
14-
ft.MaterialState.DEFAULT: ft.MouseCursor.ZOOM_OUT,
13+
ft.ControlState.HOVERED: ft.MouseCursor.WAIT,
14+
ft.ControlState.DEFAULT: ft.MouseCursor.ZOOM_OUT,
1515
},
1616
),
1717
controls=[
@@ -25,23 +25,23 @@ def example():
2525
content=ft.Text("About"),
2626
leading=ft.Icon(ft.icons.INFO),
2727
style=ft.ButtonStyle(
28-
bgcolor={ft.MaterialState.HOVERED: ft.colors.GREEN_100}
28+
bgcolor={ft.ControlState.HOVERED: ft.colors.GREEN_100}
2929
),
3030
# on_click=handle_menu_item_click
3131
),
3232
ft.MenuItemButton(
3333
content=ft.Text("Save"),
3434
leading=ft.Icon(ft.icons.SAVE),
3535
style=ft.ButtonStyle(
36-
bgcolor={ft.MaterialState.HOVERED: ft.colors.GREEN_100}
36+
bgcolor={ft.ControlState.HOVERED: ft.colors.GREEN_100}
3737
),
3838
# on_click=handle_menu_item_click
3939
),
4040
ft.MenuItemButton(
4141
content=ft.Text("Quit"),
4242
leading=ft.Icon(ft.icons.CLOSE),
4343
style=ft.ButtonStyle(
44-
bgcolor={ft.MaterialState.HOVERED: ft.colors.GREEN_100}
44+
bgcolor={ft.ControlState.HOVERED: ft.colors.GREEN_100}
4545
),
4646
# on_click=handle_menu_item_click
4747
),
@@ -62,7 +62,7 @@ def example():
6262
close_on_click=False,
6363
style=ft.ButtonStyle(
6464
bgcolor={
65-
ft.MaterialState.HOVERED: ft.colors.PURPLE_200
65+
ft.ControlState.HOVERED: ft.colors.PURPLE_200
6666
}
6767
),
6868
# on_click=handle_menu_item_click
@@ -73,7 +73,7 @@ def example():
7373
close_on_click=False,
7474
style=ft.ButtonStyle(
7575
bgcolor={
76-
ft.MaterialState.HOVERED: ft.colors.PURPLE_200
76+
ft.ControlState.HOVERED: ft.colors.PURPLE_200
7777
}
7878
),
7979
# on_click=handle_menu_item_click

python/apps/controls-gallery/examples/buttons/outlinedbutton/03_outlinedbutton_with_click_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55

66
def example():
7-
async def button_clicked(e):
7+
def button_clicked(e):
88
b.data += 1
99
t.value = f"Button clicked {b.data} time(s)"
10-
await t.update_async()
10+
t.update()
1111

1212
b = ft.OutlinedButton("Button with 'click' event", on_click=button_clicked, data=0)
1313
t = ft.Text()

python/apps/controls-gallery/examples/buttons/popupmenubutton/01_popupmenubutton_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55

66
def example():
7-
async def check_item_clicked(e):
7+
def check_item_clicked(e):
88
e.control.checked = not e.control.checked
9-
await e.control.update_async()
9+
e.control.update()
1010

1111
pb = ft.PopupMenuButton(
1212
items=[

python/apps/controls-gallery/examples/buttons/submenubutton/01_submenubutton_example.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
def example():
77
bg_container = ft.Container(height=100, expand=True, bgcolor=ft.colors.AMBER)
88

9-
async def handle_color_click(e):
9+
def handle_color_click(e):
1010
color = e.control.content.value
1111
print(f"{color}.on_click")
1212
bg_container.bgcolor = color.lower()
13-
await bg_container.update_async()
13+
bg_container.update()
1414

1515
def handle_on_hover(e):
1616
print(f"{e.control.content.value}.on_hover")
@@ -28,7 +28,7 @@ def handle_on_hover(e):
2828
ft.MenuItemButton(
2929
content=ft.Text("Blue"),
3030
style=ft.ButtonStyle(
31-
bgcolor={ft.MaterialState.HOVERED: ft.colors.BLUE}
31+
bgcolor={ft.ControlState.HOVERED: ft.colors.BLUE}
3232
),
3333
on_click=handle_color_click,
3434
on_hover=handle_on_hover,
@@ -42,7 +42,7 @@ def handle_on_hover(e):
4242
ft.MenuItemButton(
4343
content=ft.Text("Green"),
4444
style=ft.ButtonStyle(
45-
bgcolor={ft.MaterialState.HOVERED: ft.colors.GREEN}
45+
bgcolor={ft.ControlState.HOVERED: ft.colors.GREEN}
4646
),
4747
on_click=handle_color_click,
4848
on_hover=handle_on_hover,
@@ -56,7 +56,7 @@ def handle_on_hover(e):
5656
ft.MenuItemButton(
5757
content=ft.Text("Red"),
5858
style=ft.ButtonStyle(
59-
bgcolor={ft.MaterialState.HOVERED: ft.colors.RED}
59+
bgcolor={ft.ControlState.HOVERED: ft.colors.RED}
6060
),
6161
on_click=handle_color_click,
6262
on_hover=handle_on_hover,

0 commit comments

Comments
 (0)