1
0

main.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. from router import Router
  3. from nicegui import ui
  4. @ui.page('/') # normal index page (e.g. the entry point of the app)
  5. @ui.page('/{_:path}') # all other pages will be handled by the router but must be registered to also show the SPA index page
  6. def main():
  7. router = Router()
  8. @router.add('/')
  9. def show_one():
  10. ui.label('Content One').classes('text-2xl')
  11. @router.add('/two')
  12. def show_two():
  13. ui.label('Content Two').classes('text-2xl')
  14. @router.add('/three')
  15. def show_three():
  16. ui.label('Content Three').classes('text-2xl')
  17. # adding some navigation buttons to switch between the different pages
  18. with ui.row():
  19. ui.button('One', on_click=lambda: router.open(show_one)).classes('w-32')
  20. ui.button('Two', on_click=lambda: router.open(show_two)).classes('w-32')
  21. ui.button('Three', on_click=lambda: router.open(show_three)).classes('w-32')
  22. # this places the content which should be displayed
  23. router.frame().classes('w-full p-4 bg-gray-100')
  24. ui.run()