Skip to content

Commit 98e849f

Browse files
committed
Replace ElevatedButton with Button in examples
Updated all Python example files to use ft.Button instead of ft.ElevatedButton for consistency with the latest Flet API. This affects authentication, controls-gallery, routing-navigation, studio-gallery, desktop-window-manager, and other sample apps.
1 parent 1bbdf4d commit 98e849f

141 files changed

Lines changed: 559 additions & 550 deletions

File tree

Some content is hidden

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

sdk/python/examples/apps/authentication/basic-auth-async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def on_login(e):
2525
print("User ID:", page.auth.user.id)
2626

2727
page.on_login = on_login
28-
page.add(ft.ElevatedButton("Login with GitHub", on_click=login_click))
28+
page.add(ft.Button("Login with GitHub", on_click=login_click))
2929

3030

3131
ft.run(target=main, port=8550, view=ft.WEB_BROWSER)

sdk/python/examples/apps/authentication/basic-auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def on_login(e):
2525
print("User ID:", page.auth.user.id)
2626

2727
page.on_login = on_login
28-
page.add(ft.ElevatedButton("Login with GitHub", on_click=login_click))
28+
page.add(ft.Button("Login with GitHub", on_click=login_click))
2929

3030

3131
ft.run(target=main, port=8550, view=ft.WEB_BROWSER)

sdk/python/examples/apps/authentication/check-auth-results-and-toggle-ui.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
22

3-
import flet
4-
from flet import ElevatedButton, LoginEvent, Page
3+
import flet as ft
54
from flet.auth.providers import GitHubOAuthProvider
65

76

8-
def main(page: Page):
7+
def main(page: ft.Page):
98
provider = GitHubOAuthProvider(
109
client_id=os.getenv("GITHUB_CLIENT_ID"),
1110
client_secret=os.getenv("GITHUB_CLIENT_SECRET"),
@@ -15,7 +14,7 @@ def main(page: Page):
1514
def login_button_click(e):
1615
page.login(provider, scope=["public_repo"])
1716

18-
def on_login(e: LoginEvent):
17+
def on_login(e: ft.LoginEvent):
1918
if not e.error:
2019
toggle_login_buttons()
2120

@@ -30,12 +29,12 @@ def toggle_login_buttons():
3029
logout_button.visible = page.auth is not None
3130
page.update()
3231

33-
login_button = ElevatedButton("Login with GitHub", on_click=login_button_click)
34-
logout_button = ElevatedButton("Logout", on_click=logout_button_click)
32+
login_button = ft.Button("Login with GitHub", on_click=login_button_click)
33+
logout_button = ft.Button("Logout", on_click=logout_button_click)
3534
toggle_login_buttons()
3635
page.on_login = on_login
3736
page.on_logout = on_logout
3837
page.add(login_button, logout_button)
3938

4039

41-
flet.app(target=main, port=8550, view=flet.AppView.WEB_BROWSER)
40+
ft.app(target=main, port=8550, view=ft.AppView.WEB_BROWSER)

sdk/python/examples/apps/authentication/github-oauth-with-listing-repos-async.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import logging
33
import os
44

5-
import flet as ft
65
import httpx
6+
7+
import flet as ft
78
from flet.auth.providers import GitHubOAuthProvider
89
from flet.security import decrypt, encrypt
910

@@ -89,8 +90,8 @@ def toggle_login_buttons():
8990
logged_user.visible = logout_button.visible = page.auth is not None
9091

9192
logged_user = ft.Text()
92-
login_button = ft.ElevatedButton("Login with GitHub", on_click=perform_login)
93-
logout_button = ft.ElevatedButton("Logout", on_click=logout_button_click)
93+
login_button = ft.Button("Login with GitHub", on_click=perform_login)
94+
logout_button = ft.Button("Logout", on_click=logout_button_click)
9495
repos_view = ft.ListView(expand=True)
9596
page.on_login = on_login
9697
page.on_logout = on_logout

sdk/python/examples/apps/authentication/github-oauth-with-listing-repos.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import logging
33
import os
44

5-
import flet as ft
65
import httpx
6+
7+
import flet as ft
78
from flet.auth.providers import GitHubOAuthProvider
89
from flet.security import decrypt, encrypt
910

@@ -86,8 +87,8 @@ def toggle_login_buttons():
8687
logged_user.visible = logout_button.visible = page.auth is not None
8788

8889
logged_user = ft.Text()
89-
login_button = ft.ElevatedButton("Login with GitHub", on_click=perform_login)
90-
logout_button = ft.ElevatedButton("Logout", on_click=logout_button_click)
90+
login_button = ft.Button("Login with GitHub", on_click=perform_login)
91+
logout_button = ft.Button("Logout", on_click=logout_button_click)
9192
repos_view = ft.ListView(expand=True)
9293
page.on_login = on_login
9394
page.on_logout = on_logout

sdk/python/examples/apps/authentication/linkedin-login.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
22

3-
import flet
4-
from flet import ElevatedButton, Page
3+
import flet as ft
54
from flet.auth import OAuthProvider
65

76

8-
def main(page: Page):
7+
def main(page: ft.Page):
98
provider = OAuthProvider(
109
client_id=os.getenv("LINKEDIN_CLIENT_ID"),
1110
client_secret=os.getenv("LINKEDIN_CLIENT_SECRET"),
@@ -27,7 +26,7 @@ def on_login(e):
2726
print("Access token:", page.auth.token.access_token)
2827

2928
page.on_login = on_login
30-
page.add(ElevatedButton("Login with LinkedIn", on_click=login_click))
29+
page.add(ft.Button("Login with LinkedIn", on_click=login_click))
3130

3231

33-
flet.app(target=main, port=8550, view=flet.AppView.WEB_BROWSER)
32+
ft.app(target=main, port=8550, view=ft.AppView.WEB_BROWSER)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def animate(e):
3131
c.content = c2 if c.content == c1 else c1
3232
c.update()
3333

34-
return ft.Column(controls=[c, ft.ElevatedButton("Animate!", on_click=animate)])
34+
return ft.Column(controls=[c, ft.Button("Animate!", on_click=animate)])

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def dismiss_dialog(e):
1919
def open_dlg(e):
2020
e.control.page.show_dialog(cupertino_alert_dialog)
2121

22-
return ft.ElevatedButton("Open CupertinoAlertDialog", on_click=open_dlg)
22+
return ft.Button("Open CupertinoAlertDialog", on_click=open_dlg)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import flet as ft
22

3-
name = "Basic ElevatedButtons"
3+
name = "Basic Buttons"
44

55

66
def example():
77
return ft.Column(
88
controls=[
9-
ft.ElevatedButton(content="Elevated button"),
10-
ft.ElevatedButton("Disabled button", disabled=True),
9+
ft.Button(content="Elevated button"),
10+
ft.Button("Disabled button", disabled=True),
1111
]
1212
)

sdk/python/examples/apps/controls-gallery/examples/buttons/elevatedbutton/02_elevatedbuttons_with_icons.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import flet as ft
22

3-
name = "ElevatedButtons with icons"
3+
name = "Buttons with icons"
44

55

66
def example():
77
return ft.Column(
88
controls=[
9-
ft.ElevatedButton("Button with icon", icon="chair_outlined"),
10-
ft.ElevatedButton(
9+
ft.Button("Button with icon", icon="chair_outlined"),
10+
ft.Button(
1111
"Button with colorful icon",
1212
icon="park_rounded",
1313
icon_color="green400",

0 commit comments

Comments
 (0)