1

I have a problem that when I turn the device over, the contents get mixed up, are there any ways to prevent the phone screen from turning over?

import flet as ft

def main(page: ft.Page):
    page.title = "Routes Example"

    troute = ft.TemplateRoute(page.route)

    if troute.match("/books/:id"):
        print("Book view ID:", troute.id)
    elif troute.match("/account/:account_id/orders/:order_id"):
        print("Account:", troute.account_id, "Order:", troute.order_id)
    else:
        print("Unknown route")
        
    def route_change(route):
        page.views.clear()
        page.views.append(
            ft.View(
                "/",
                [
                    ft.AppBar(title=ft.Text("Flet app"), bgcolor=ft.colors.SURFACE_VARIANT),
                    ft.ElevatedButton("Visit Store", on_click=lambda _: page.go("/store")),
                ],
            )
        )
        if page.route == "/store":
            page.views.append(
                ft.View(
                    "/store",
                    [
                        ft.AppBar(title=ft.Text("Store"), bgcolor=ft.colors.SURFACE_VARIANT),
                        ft.ElevatedButton("Go Home", on_click=lambda _: page.go("/")),
                    ],
                )
            )
        page.update()

    def view_pop(view):
        page.views.pop()
        top_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)


ft.app(target=main)

I tried to cheat, check if the screen width exceeds the norm, but the whole screen shows a message that it should be flipped for more convenient use

1

1 Answer 1

0

It looks like that hasn't been implemented yet according to an open github issue

Sign up to request clarification or add additional context in comments.

4 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
@Rich how is this link-only?
@Rich What other information should I have included? As far as I can tell that's where the issue is sitting right now: unimplemented, unassigned, and untracked. I'm new here, so more information would be a big help to my future answers
@kviking I think what you've written is ok. if you want to improve, some general tips from me that might be applicable here can be found at meta.stackoverflow.com/a/425696/11107541

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.