Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavigationRail not displayed when returned by build method #287

Closed
clstaudt opened this issue Sep 7, 2022 · 1 comment
Closed

NavigationRail not displayed when returned by build method #287

clstaudt opened this issue Sep 7, 2022 · 1 comment

Comments

@clstaudt
Copy link

clstaudt commented Sep 7, 2022

As shown in the ToDoApp tutorial, I would like to create a class representing the main application (window). This application should have a side bar containing a NavigationRail. The problem: When the NavigationRail is returned by the build method of the App class (rather than added to the page directly), it is not displayed.

(In general it would be great to have a code example or template for how to implement such a common app window layout - sidebar and main window area changing depending on sidebar selection - with flet.)

import flet
from flet import (
    UserControl,
    Page,
    View,
    Text,
    Column,
    Row,
    KeyboardEvent,
    SnackBar,
    NavigationRail,
    NavigationRailDestination,
    VerticalDivider,
    Icon,
)
from flet import icons

from tuttle.controller import Controller

from views import (
    ContactView,
)

class App(UserControl):
    """Main application window."""

    def __init__(
        self,
    ):
        super().__init__()

    def build(self):
        return Row(
            [
                NavigationRail(
                    destinations=[
                        NavigationRailDestination(
                            icon=icons.AREA_CHART_OUTLINED,
                            selected_icon=icons.AREA_CHART,
                            label="Dashboard",
                        )
                    ],
                    extended=True,
                ),
                VerticalDivider(width=1),
            ]
        )


def main(page: Page):

    app = App()

    page.add(
        app,
    )

    page.update()


flet.app(
    target=main,
)
@FeodorFitsner FeodorFitsner added this to the Controls-S2 milestone Sep 20, 2022
@FeodorFitsner FeodorFitsner removed this from the Controls-S2 milestone Oct 6, 2022
@FeodorFitsner
Copy link
Contributor

Closing in favor of #303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants