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.9.tar.gz (17.2 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.9-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_left-0.0.9.tar.gz
  • Upload date:
  • Size: 17.2 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.9.tar.gz
Algorithm Hash digest
SHA256 e2883bd0c2fc93ac537529f8d279dea6d8b46ac877188131d9e5bfbc41f5c82a
MD5 68661d9135831f4c9c6621e60f3298a9
BLAKE2b-256 28f9cffc619258ce32517c64124f26ae0e4dfb8aa301c8df06054f0d3458bce3

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_left-0.0.9.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.9-py3-none-any.whl.

File metadata

  • Download URL: python_left-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 20.9 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 052d46b46afb2bcda7faffe0f6d9c28a50aedd251ff62c4d9d65210c7cc28dce
MD5 0db748d1f0d15d166ae1495e769109d7
BLAKE2b-256 6246324363893908776112b38f3dd57c2c44a4eb4cb8b44c0c84e227463c5ff7

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_left-0.0.9-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