├── README.md ├── __pycache__ └── views.cpython-310.pyc ├── app.py ├── pages ├── __pycache__ │ ├── forgotpassword.cpython-310.pyc │ ├── home.cpython-310.pyc │ └── login.cpython-310.pyc ├── about.py ├── forgotpassword.py ├── home.py ├── login.py └── signup.py └── views.py /README.md: -------------------------------------------------------------------------------- 1 | # Routing-and-Navigation-in-Python-flet 2 | -------------------------------------------------------------------------------- /__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Mr-Newton/Routing-and-Navigation-in-Python-flet/ce2f3ea1490edbb0e76aa210115b0df18551b304/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | from views import views_handler 3 | 4 | def main(page: Page): 5 | 6 | def route_change(route): 7 | print(page.route) 8 | page.views.clear() 9 | page.views.append( 10 | views_handler(page)[page.route] 11 | ) 12 | 13 | 14 | page.on_route_change = route_change 15 | page.go('/') 16 | 17 | 18 | 19 | app(target=main) -------------------------------------------------------------------------------- /pages/__pycache__/forgotpassword.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Mr-Newton/Routing-and-Navigation-in-Python-flet/ce2f3ea1490edbb0e76aa210115b0df18551b304/pages/__pycache__/forgotpassword.cpython-310.pyc -------------------------------------------------------------------------------- /pages/__pycache__/home.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Mr-Newton/Routing-and-Navigation-in-Python-flet/ce2f3ea1490edbb0e76aa210115b0df18551b304/pages/__pycache__/home.cpython-310.pyc -------------------------------------------------------------------------------- /pages/__pycache__/login.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Mr-Newton/Routing-and-Navigation-in-Python-flet/ce2f3ea1490edbb0e76aa210115b0df18551b304/pages/__pycache__/login.cpython-310.pyc -------------------------------------------------------------------------------- /pages/about.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1Mr-Newton/Routing-and-Navigation-in-Python-flet/ce2f3ea1490edbb0e76aa210115b0df18551b304/pages/about.py -------------------------------------------------------------------------------- /pages/forgotpassword.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | 3 | class ForgotPassword(UserControl): 4 | def __init__(self): 5 | super().__init__() 6 | 7 | def build(self): 8 | return Column() -------------------------------------------------------------------------------- /pages/home.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | class Home(UserControl): 3 | def __init__(self,page): 4 | super().__init__() 5 | self.page = page 6 | 7 | def build(self): 8 | return Column( 9 | controls=[ 10 | Container( 11 | height=800,width=300, 12 | bgcolor='red', 13 | content=Column( 14 | controls=[ 15 | Text('Welcome to the homepage'), 16 | Container( 17 | on_click= lambda _: self.page.go('/login') , 18 | content=Text('Goto Login',size=25,color='black') 19 | ) 20 | ] 21 | ) 22 | ) 23 | ] 24 | ) -------------------------------------------------------------------------------- /pages/login.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | 3 | class Login(UserControl): 4 | def __init__(self,page): 5 | super().__init__() 6 | self.page = page 7 | 8 | def build(self): 9 | return Column( 10 | controls=[ 11 | Container( 12 | height=800,width=200, 13 | bgcolor='blue', 14 | content=Column( 15 | controls=[ 16 | Text('Welcome back \n This is the login pages'), 17 | Container( 18 | on_click= lambda _: self.page.go('/'), 19 | content=Text('Goto Home',size=25,color='black') 20 | ) 21 | ] 22 | ) 23 | ) 24 | ] 25 | ) -------------------------------------------------------------------------------- /pages/signup.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | 3 | class Signup(UserControl): 4 | def __init__(self): 5 | super().__init__() 6 | 7 | def build(self): 8 | return Column() -------------------------------------------------------------------------------- /views.py: -------------------------------------------------------------------------------- 1 | from flet import * 2 | from pages.home import Home 3 | from pages.login import Login 4 | 5 | def views_handler(page): 6 | return { 7 | '/':View( 8 | route='/', 9 | controls=[ 10 | Home(page) 11 | ] 12 | ), 13 | '/login':View( 14 | route='/login', 15 | controls=[ 16 | Login(page) 17 | ] 18 | ), 19 | } --------------------------------------------------------------------------------