A Model-based router for Flet applications that simplifies the creation of multi-page applications
Project description
Flet Model
A Model-based router for Flet applications that simplifies the creation of multi-page applications.
Installation
pip install flet-model
Usage
Here's a simple example of how to use Flet Model:
import flet as ft
from flet_model import Model, Router
class First(Model):
route = 'first'
vertical_alignment = ft.MainAxisAlignment.CENTER
horizontal_alignment = ft.CrossAxisAlignment.CENTER
appbar = ft.AppBar(
title=ft.Text("First View"),
center_title=True,
bgcolor=ft.Colors.SURFACE)
controls = [
ft.ElevatedButton("Go to Second Page", on_click="go_second")
]
def go_second(self, e):
self.page.go('/first/second')
class Second(Model):
route = 'second'
title = "Test"
vertical_alignment = ft.MainAxisAlignment.CENTER
horizontal_alignment = ft.CrossAxisAlignment.CENTER
appbar = ft.AppBar(
title=ft.Text("Second View"),
center_title=True,
bgcolor=ft.Colors.SURFACE)
controls = [
ft.ElevatedButton("Go to First", on_click="go_first")
]
def go_first(self, e):
self.page.go('first')
def main(page: ft.Page):
page.title = "Title"
page.theme_mode = "light"
# Initialize router with route mappings
Router(
{'first': First(page)},
{'second': Second(page)}
)
page.go(page.route)
ft.app(target=main)
Features
- Model-based view definition
- Automatic route handling
- Event binding
- Support for nested routes
- Easy navigation between views
- View caching for improved performance
- Comprehensive UI component configuration (AppBar, BottomAppBar, FAB, etc.)
- Auto-binding of event handlers with caching
- Thread-safe initialization hooks (init and post_init)
- Support for overlay controls
- Customizable layout properties (alignment, padding, spacing)
- Keyboard event handling
- Scroll event handling
- Flexible control definition (static list or callable)
- Built-in view state management
- Navigation drawer support (both start and end)
- Built-in support for fullscreen dialogs
License
This project is licensed under the MIT License.
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
flet_model-0.1.3.tar.gz
(7.8 kB
view details)
Built Distribution
File details
Details for the file flet_model-0.1.3.tar.gz
.
File metadata
- Download URL: flet_model-0.1.3.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5483a347c236d90e9cbcf7f08b765fc71de8dab143545a76c309b93792680909 |
|
MD5 | 2d6ba23a99d8a9eed8afdff5bef1d1a4 |
|
BLAKE2b-256 | 6976b88b2ca549aa272155ed8d92590dbc6b299b4a399b59a84c7d89110fa598 |
File details
Details for the file flet_model-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: flet_model-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 033aa2e5cd822ba52e66e9512f0b3d78ce6fde16a567d77090f5529d11d9aeb8 |
|
MD5 | 960305339db0100158b4c1b392766f65 |
|
BLAKE2b-256 | ff77fabbbab3650bfa9a09bab65495b329967c723f75476fe8450a0f4296fb95 |