[Question][NOOB]How to use a NavigationBar to actually switch between pages/tabs just like how you would do that whilst using Tabs?? #3629
Unanswered
CoderMaximus
asked this question in
Q&A
Replies: 1 comment
-
Here is an example: import flet as ft
def main(page: ft.Page):
def handle_nav_change(e):
if e.control.selected_index == 0:
page.title = "Explore!"
page.controls = [ft.Text("Explore!")] # list of controls to be displayed in the page when the 1st navbar item is selected
elif e.control.selected_index == 1:
page.title = "Commute!"
page.controls = [ft.Text("Commute!")]
elif e.control.selected_index == 2:
page.title = "Bookmark!"
page.controls = [ft.Text("Bookmark!")]
page.update()
page.title = "NavigationBar Example"
page.navigation_bar = ft.NavigationBar(
on_change=handle_nav_change,
destinations=[
ft.NavigationBarDestination(icon=ft.icons.EXPLORE, label="Explore"),
ft.NavigationBarDestination(icon=ft.icons.COMMUTE, label="Commute"),
ft.NavigationBarDestination(
icon=ft.icons.BOOKMARK_BORDER,
selected_icon=ft.icons.BOOKMARK,
label="Explore",
),
],
)
page.add(ft.Text("Explore!"))
ft.app(target=main) I made a suggestion to have this simplified: #3316 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
I need to switch between 4-5 pages/ tabs BUT only using NavigationBar
Code sample
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions