Code Monkey home page Code Monkey logo

flet_navigator's Introduction

FletNavigator V2.


FletNavigator & FletReStyle.

Simple and fast navigator (router) for Flet (Python) that allows you to create multi-page applications! [pip install flet_navigator].

Click for documentation.


Example:

from flet import app, Text

from flet_navigator import PageData, render, anon, route


@route('/')
def main_page(pg: PageData) -> None:
    pg.add(Text('Main Page!')) # or `pg.page.add`.

@route('second_page')
def second_page(pg: PageData) -> None:
    ... # Second page content.

app(anon(render))


(Old Example GIF).

See documentation here.


FletNavigator v2.7.5.

flet_navigator's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fasilwdr

flet_navigator's Issues

__init__.py bug

Describe your problem:
Line 466, if parameters is None, the len() statement will fail.

Reproducing the problem:
Code..

Media (optional):
Screenshot or video..

flet_navigator version, flet version, OS:
FletNavigator version, Flet Version, OS..

Additional:
...

[ISSUE]

Describe your problem:
It seems this code doesn't work anymore. I don't know why?
error message:
db= pg.arguments[0]
~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Reproducing the problem:
from flet import app, Page, Text, TextThemeStyle, TextField,FilledButton,WEB_BROWSER

from flet_navigator import FletNavigator, PageData, ROUTE_404
def main_page(pg: PageData) -> None:
pg.page.add(Text(f'Main Page.', style=TextThemeStyle.DISPLAY_MEDIUM))

text = TextField()
db= pg.arguments[0]
print(db)
# print(school_db.get_grade())

pg.page.add(text, FilledButton('Send.', on_click=lambda _: pg.navigator.navigate(f'second_page?text={text.value}', pg.page)))

def second_page(pg: PageData) -> None:
pg.page.add(Text(f'Second Page!', style=TextThemeStyle.DISPLAY_SMALL))

for parameter in pg.parameters:
    pg.page.add(Text(f'{parameter}: {pg.parameters[parameter]}'))

def route_404(pg: PageData) -> None:
... # 404 Page Content.

def login_page(pg: PageData) -> None:
pg.navigator.navigate("main_page", pg.page, (1,))

def main(page: Page) -> None:
# Initialize navigator.
flet_navigator = FletNavigator(page, # Specify page.
{
'/': login_page, # Main page route,
'main_page': main_page, # Main page route,
'second_page': second_page, # Second page route,
ROUTE_404: route_404 # 404 page route
}, lambda route: print(f'Route changed!: {route}') # Route change handler (optional).
)

# Render current page.
flet_navigator.render(page)

app(target=main)

Media (optional):
Screenshot or video..

flet_navigator version, flet version, OS:
FletNavigator version, Flet Version, OS..

Additional:
...

NavigationBar not showing

Describe your new feature:
if I add a navigationbar (at the bottom of the screen), and when I navigate to a second page, the navigationbar won't show ( I want to keep the same bar) . Maybe add an option to show/not show/add a new one. Thanks

Additional:
...

docs not complete why my app blank white

my code

from flet import *
from flet_navigator import VirtualFletNavigator, PageData, ROUTE_404

def home(pg:PageData):
return AppBar(
title=Text("home")
)

def main(page:Page):
flet_navigator = VirtualFletNavigator(
{
"/":home,
},lambda route: print(f"nama rute :{route}")

		)
flet_navigator.render(page)

flet.app(target=main)

AppBar

Minor issue. If I set a ft.AppBar in homepage, when I navigate to the 2nd page, in which I don’t need the AppBar to be displayed anymore , the AppBar is still there. I need to set pg.page.appbar = None in the 2nd page and it works.

flet_navigator error

Hi , I am interested in the flet_navigator and just tried the example (I downloaded it and named it testrouting.py) . I have this error. I tested on Linux Mint and Windows 11, using flet 0.11.0 and python 3.12.

File "/home/python_projects/flet_projects/.venv/lib/python3.12/site-packages/flet_runtime/app.py", line 359, in on_session_created
session_handler(page)
File "/home/python_projects/flet_projects/testrouting.py", line 72, in main
flet_navigator.render(page) # Render main page.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/python_projects/flet_projects/.venv/lib/python3.12/site-packages/flet_navigator/init.py", line 83, in render
self.routes[route](page, self, args, self._nav_previous_routes[-2] if len(self._nav_previous_routes) >= 2 else '/', route_parameters)
TypeError: main_page() takes 3 positional arguments but 5 were given

I can't upload an image in any PageData..

Describe your problem:
First of all, I would like to congratulate you. Flet_Navigator is an excellent product and very easy to use. I just made software for a client using it, and the usability and performance really captivated me.
Now, I have a problem... I need to upload an image using "assets" and I can't...
I set the asset path, but when I try to load an image on a specific PageData or on the main page (ft.page) the image does not appear.

Reproducing the problem:
This code bellow is what I need. I´m not using Flet_Navigatot in it .It's just to you understand the requirement.

import flet as ft
from pathlib import Path
assets=f'{Path(file).parent}\atelier-costura'
logo=f'\manual\logo-4.jpg'
print(dir)

def main(page: ft.Page):
page.title = "Images Example"
page.theme_mode = ft.ThemeMode.LIGHT
page.padding = 50
page.update()

img = ft.Image(
    src=logo,
    width=80,
    height=80,
    fit=ft.ImageFit.COVER,
    border_radius=1,
)
texto=ft.Text('Atelier Tesoura Mágica',font_family='tahoma',size=20,color=ft.colors.PINK, )

cabecalho=ft.ResponsiveRow([ft.Column(col={"xs":4,"sm": 3, "md":2 , "xl":1},controls=[img]),
                            ft.Column(col={"xs":8,"sm": 6, "md": 5, "xl": 4},controls=[texto]),
                            ],
                           vertical_alignment=ft.CrossAxisAlignment.CENTER,alignment='left')
page.add(cabecalho)

page.update()

ft.app(target=main, view=ft.AppView.WEB_BROWSER,assets_dir=assets)

Media (optional):
Screenshot or video..

flet_navigator version, flet version, OS:
Name: flet_navigator
Version: 2.6.5

Name: flet
Version: 0.21.1

Windows 10

Additional:
...

[ISSUE]

Describe your problem:
Getting this error
from flet_navigator import VirtualFletNavigator, Any, ROUTE_404
File "C:\Users\Harfho.virtualenvs\fletdemo-ECSyV_o1\lib\site-packages\flet_navigator_init_.py", line 19, in
_global_templates: dict[str, 'TemplateDefinition'] = {}
TypeError: 'type' object is not subscriptable

Reproducing the problem:
from flet import app, Text

from flet_navigator import PageData, render, anon, route

@route('/')
def main_page(pg: PageData) -> None:
pg.add(Text('Main Page!')) # or pg.page.add.

@route('second_page')
def second_page(pg: PageData) -> None:
... # Second page content.

app(anon(render, virtual=True))

Media (optional):
image

flet_navigator version, flet version, OS:
flet 0.21.2
flet_navigator 2.7.5

Additional:
...

[ISSUE] Container "expand=True" doesn't work

Describe your problem:
If you try to expand Container layout it doesn't work, is it a known bug (flexible support)?

Reproducing the problem:
Just try to expand a Container with expand=True

Media (optional):
image

flet_navigator version, flet version, OS:
FletNavigator version 2.6.5, Flet Version 0.20.2, OS Windows 11 Home 10.0.22631

Additional:
...

A possible performance issue when returning to the previous page

Describe your problem:
I'm really not sure if the bug is in Flet_Navigator. I just want you to help me think about the source of the problem.
The system performs Kanban control of work orders
My page structure:
Home - Login/pawwword. It is only assessed when we enter the system.
Page1 - Entry page containing a Datatable of work orders whose origin is a dataframe, which is assembled by importing values from the Postgres database.
Page2 - Another Datatable with customer data imported from a Postgres database
Page3 - Analytical data of the work order, containing two dataframes with little data.

The problem occurs when I return from page 2 or 3 to page 1
Currently the service order datatable has 180 records...

Reproducing the problem:
The code is too big. Maybe I could post a islice of it, if you want...

Media (optional):
Screenshot or video..

flet_navigator version, flet version, OS:

`Name: flet_navigator
Version: 2.6.5

Name: flet
Version: 0.21.1

Windows10 / Apache / Android

Additional:
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.