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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python-left-0.0.4.tar.gz
.
File metadata
- Download URL: python-left-0.0.4.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15c0f86118a1bcc24f9966016ae108c23f5c1d5e7aa6a89a030f418875369244 |
|
MD5 | 176dd5a2987b5a6177f90880317e1611 |
|
BLAKE2b-256 | 46b7effddcf1e40f405b7c2cbfe6c27da2767493dcf5cf3751065528e19b99c5 |
File details
Details for the file python_left-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: python_left-0.0.4-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df087bef627ca3daef32c416e4b6ab08e6eef1b4f6aa34ccf6aae0e178a2073 |
|
MD5 | 069ac82a35486162bccb3644729523a4 |
|
BLAKE2b-256 | bdd304b13613376d0d096cbf684ea07ec500d0893b0114b023cc1cf8e679a525 |