Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Flet Page Navigation

$
0
0

I have an app I'm making but the top navigation wont reroute to the Account Pagethis is the App bar Controls

# App Bar Controlsclass Appbar(UserControl):    def __init__(self, page) -> None:        self.page = page        super().__init__()    def account_page(self, event):        self.page.go('/account')    def test_01(self):        print('Ola Comsta')    def topnav(self):        return AppBar(            center_title=Text('Main Page'),            leading=IconButton(icons.MENU_ROUNDED, on_click=self.test_01),            title = navbar.UserData('Thabang Teddy', 'Big Data Software Developer'),            actions=[                PopupMenuButton(                    items=[                        PopupMenuItem(text='Account', on_click=self.account_page),                        PopupMenuItem(text='Settings'),                    ],                ),            ],            bgcolor='blue800'        )

The main function that has the rerouting functionalities and all the pages is this one:

def main(page: Page) -> None:    page.title = "Index-I"    page.window_width = 400       # window's width is 200 px    page.window_height = 800       # window's height is 200 px    page.window_resizable = False     # page.horizontal_alignment='center'    # page.vertical_alignment='center'    page.scroll = ScrollMode.AUTO    appbar = Appbar(page)    def route_change(e: RouteChangeEvent) -> None:        page.views.clear()        page.views.append(            View(                route='/',                controls=[                Text(value='Index-I', size=50, color='white'),                IconButton(                    icon=icons.NAVIGATE_NEXT,                    icon_color="blue400",                    icon_size=40,                    tooltip="Open",                    on_click=lambda _: page.go('/mainpage'))],                vertical_alignment=MainAxisAlignment.CENTER,                horizontal_alignment=CrossAxisAlignment.CENTER,                spacing=26,            ),        )        # MainPage View        if page.route == "/mainpage":            topnav = appbar.topnav()            page.views.append(            View(                route='/mainpage',                controls=[                    topnav,                    FloatingActionButton(                                icon=icons.ARROW_BACK_IOS_ROUNDED,                                on_click=lambda _: page.go('/')                            ),                    Text(                        value = 'Analytics',                        weight = 'BOLD',                        size=25,                        text_align = 'CENTER'                    ),                    Row([                        Text(                            value = 'BALANCE',                            size=10),                        Text(                            value = '$40 000.00',                            weight= 'BOLD'),                    ])        ]            )            )          # Account View        if page.route == "/account":            topnav = appbar.topnav()            page.views.append(            View(                route='/account',                controls=[                    topnav,                    FloatingActionButton(                                icon=icons.ARROW_BACK_IOS_ROUNDED,                                on_click=lambda _: page.go('/')                            ),                    Text(                        value = 'Profile',                        weight = 'BOLD',                        size=25,                        text_align = 'CENTER'                    ),                ]            )            )        page.update()    def view_pop(e: ViewPopEvent) -> None:        page.views.pop()        top_view: View = page.views[-1]        page.go(top_view.route)    page.on_route_change = route_change    page.on_view_pop = view_pop    page.go(page.route)

I want to basically change the pages or atleast reroute to the desired pages but i keep getting an error about:self.page.go('/account') ^^^^^^^^^^^^ Attribute Error: 'None Type' object has no attribute 'go'I don't know what to do anymore.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>