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.8.tar.gz (13.7 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.8-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python_left-0.0.8.tar.gz
  • Upload date:
  • Size: 13.7 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.8.tar.gz
Algorithm Hash digest
SHA256 4129554d874c378b60d171281d0ab6abe09e8f44f8f4c3fd53c27cc97a6b65a4
MD5 e9f5bd347cd9282945240d0aeef88268
BLAKE2b-256 a0458d78dd833b2447bb47818958c5ca0ebcda891d73eac4bd0756ef01ea673f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: python_left-0.0.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a062f3055de9af2a4a8fc5a4e0d72afdc0c50402d3aeeefe7a73af24c0234cde
MD5 66bde76ce46372615a684506486e2d58
BLAKE2b-256 1dbf8ade5ada5fac115221eff74c5e60b5ba62d895a3b2f92cb4ee6aa551a8bd

See more details on using hashes here.

Provenance

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