Skip to main content

FlowViewFt es una libreria para crear aplicaciones con Flet sinplificando las rutas y el manejo de estados.

Project description

📦 FlowViewFt - Enrutador dinámico para Flet

FlowViewFt es una librería modular diseñada para simplificar la creación, organización y navegación entre vistas en proyectos desarrollados con Flet. Su enfoque está basado en el concepto de "flujo" (Flow), permitiendo transiciones naturales y estructuradas entre páginas, lo que facilita el mantenimiento y la escalabilidad del código.


🚀 Instalación

pip install FlowViewFt

🧠 Conceptos Clave

  • FlowViewFtParams: Encapsula los parámetros que se pueden pasar entre rutas.
  • FlowViewFtState: Maneja el estado de una vista o componente de forma organizada.
  • FlowViewFtView: Clase base para construir vistas reutilizables e independientes.

⚙️ Uso básico

main.py

import flet as ft
from FlowViewFt import FlowViewFt, route
from view.home_view import HomeView
from view.counter_view import CounterView

def main(page: ft.Page):
    page.title = "Counter App"

    FlowViewFt(
        page=page,
        routes=[
            route("/", HomeView),
            route("/counter", CounterView),
        ],
        init_route="/",
    )

ft.app(target=main)

state/CounterState.py

from FlowViewFt import FlowViewFtState
import flet as ft
class counter_state(FlowViewFtState):
    def __init__(self, page):
        super().__init__(page)
        self.txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(self,e):
        if self.txt_number.value is not None:
            self.txt_number.value = str(int(self.txt_number.value) - 1)
        self.update()

    def plus_click(self,e):
        if self.txt_number.value is not None:
            self.txt_number.value = str(int(self.txt_number.value) + 1)
        self.update()

view/home_view.py

import flet as ft
from FlowViewFt import FlowViewFtView

class HomeView(FlowViewFtView):
    def build(self):
        return ft.View(
            controls=[
                ft.Text("Welcome to CounterApp", size=30),
                ft.ElevatedButton(
                    "Go to Counter", 
                    on_click=lambda _: self.page.go("/counter")
                ),
            ]
        )

view/counter_view.py

import flet as ft
from FlowViewFt import FlowViewFtView
from state.CounterState import counter_state

class CounterView(FlowViewFtView):
    def __init__(self, page):
        super().__init__(page)
        self.state = counter_state(self.page)

    def build(self):
        return ft.View(
            horizontal_alignment=ft.CrossAxisAlignment.CENTER,
            vertical_alignment=ft.MainAxisAlignment.CENTER,
            controls=[
                ft.Row(
                    controls=[
                        ft.IconButton(ft.Icons.REMOVE, on_click=self.state.minus_click),
                        self.state.txt_number,
                        ft.IconButton(ft.Icons.ADD, on_click=self.state.plus_click),
                    ],
                    alignment=ft.MainAxisAlignment.CENTER,
                ),
                ft.ElevatedButton(
                    "Go to Home",
                    on_click=lambda _: self.pop_go("/"),
                ),
            ]
        )

🤝 Contribuciones

¡Las contribuciones son bienvenidas! Puedes enviar pull requests o sugerencias abriendo un issue en el repositorio de GitHub.


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

flowviewft-0.1.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

flowviewft-0.1.3-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file flowviewft-0.1.3.tar.gz.

File metadata

  • Download URL: flowviewft-0.1.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for flowviewft-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e75418bd6f6fa061828dc99982b625b1404f526116b916e8e1424f8a3dfe2801
MD5 7e306fd89c42c88e22f662408098d8bf
BLAKE2b-256 e411d1f66b27ae8237e6004f8c3704e4b17de2f624571ff0dfdfb7a9701052fd

See more details on using hashes here.

File details

Details for the file flowviewft-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flowviewft-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for flowviewft-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9989b4f6e430d0518cce9b931c5a017f8c133cae8137a6a55bfee927dfc5271a
MD5 694e799e02ae587150d01fee7af9e548
BLAKE2b-256 c19fba15583925ec4027f6a320b7ba5b0c353831e66d26c4ef9f846d90bc5147

See more details on using hashes here.

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