class_example.py 519 B

123456789101112131415161718
  1. import theme
  2. from message import message
  3. from nicegui import ui
  4. class ClassExample:
  5. def __init__(self) -> None:
  6. """The page is created as soon as the class is instantiated.
  7. This can obviously also be done in a method, if you want to decouple the instantiation of the object from the page creation.
  8. """
  9. @ui.page('/b')
  10. def page_b():
  11. with theme.frame('- Page B -'):
  12. message('Page B')
  13. ui.label('This page is defined in a class.')