Skip to main content

Simple routing for the Flet framework.

Project description

FletRt


FletRt is a really simple routing solution for the Flet framework, developed mainly for personal use.

Flet is a Python framework for building cross-platform desktop applications with web technologies. FletRt allows you to create multiple views for your Flet app and navigate between them using routes.

Please note that this project is still incomplete and lacks many features available on Flet.

This project core is slightly based off CodingJQ's Routing in Flet with Python in 3 Min (Tutorial)

Installation


You can install FletRt by using the following command:

pip install fletrt

Sample usage


main.py:

import flet as ft
from fletrt import Router

from page_a import PageA
from page_b import PageB


def main(page: ft.Page):
    Router(page, routes={
        '/page-a': PageA(),
        '/page-b': PageB()
    }, starting_route='/page-a')


ft.app(target=main)

page_a.py:

import flet as ft
from fletrt import RouteView


class PageA(RouteView):
    def body(self) -> ft.Container:
        return ft.Container(
            ft.Column(
                controls=[
                    ft.Text("Hello World, from Page A!"),
                    ft.ElevatedButton("Go to Page B", on_click=lambda _: self._page.go('/page-b'))
                ]
            )
        )

page_b.py:

import flet as ft
from fletrt import RouteView


class PageB(RouteView):
    def body(self) -> ft.Container:
        return ft.Container(
            ft.Column(
                controls=[
                    ft.Text("Hello World, from Page B!"),
                ]
            )
        )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fletrt-0.0.2.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

fletrt-0.0.2-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page