Skip to main content

A Minimalist Flet Framework

Project description

LEFT, a Minimalist Flet Framework

A very simple framework using the flet library - the bare boilerplate code I use to get some apps up and running.

I have deliberately kept things extremely simple - it doesn't attempt to hide the flet internals, very little enforced convention/configuration, and only a tiny reliance on some 'magic' in the React-influenced state management in the view layer (even this is not mandatory).

Its up to the end user to organise their implementation in a consistent and logical manner that works for them.

dev usage (requires python >= 3.10)

pip install python-left

See Developer Guide and sampleapp/ for a more fully-fledged CRUD-app example.

Here is the simplest possible app usage:

import flet as ft
from left import LeftApp, LeftController, LeftView
from left.sharedcomponents import loading_spinner
from left.helpers import redirect


class MyView(LeftView):
    def __init__(self):
        self.state = {"message": None}

    def update_state(self, **new_state):
        self.state.update(new_state)

    @property
    def appbar(self):
        return ft.AppBar(
            actions=[
                ft.ElevatedButton("Home", on_click=lambda _: redirect("/")),
                ft.ElevatedButton("Page2", on_click=lambda _: redirect("/page/view/page2"))
            ]
        )

    @property
    def controls(self):
        if self.state["message"] is None:
            return [loading_spinner()]
        return [
            ft.Text(self.state["message"])
        ]


class MyController(LeftController):
    def index(self):
        view = MyView()
        self._mount_view(view)
        view.update_state(message="welcome to the app!")

    def load_page(self, uid):
        view = MyView()
        self._mount_view(view)
        view.update_state(message=f"Display contents for {uid} here...")


def on_route_change(page, parts):
    match parts:
        case ['']:
            MyController(page).index()
        case ['page', 'view', uid]:
            MyController(page).load_page(uid)
        case _:
            print(f"Unrecognised route: {page.route}")


LeftApp(
    router_func=on_route_change,
    default_title="A Very Simple App")

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

python_left-0.0.7.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_left-0.0.7-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file python_left-0.0.7.tar.gz.

File metadata

  • Download URL: python_left-0.0.7.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_left-0.0.7.tar.gz
Algorithm Hash digest
SHA256 29d3ffd47e8ef36baaa7686d672eb38982dd3569dc88ef797bdf0fd7bdc9d50b
MD5 d673d2d6dfaa7db87b2fc58443c8ab3e
BLAKE2b-256 ac78b5e4135e25e6da7413cd46737b756bcc50c8d672cf9284cfc1f034b755bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_left-0.0.7.tar.gz:

Publisher: publish-to-pypi.yml on nickpeck/left

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_left-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: python_left-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for python_left-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a55756f22184803b45bc85e98c7bbcd84e3a162658cead15037f1239dbe2c785
MD5 e0aa73a80cee743361e62d30f7fc684c
BLAKE2b-256 02f615003531737243a3cd00a6fe86e8451afa02e68efa49e42d7641461cc96f

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_left-0.0.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on nickpeck/left

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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