Parcourir la source

show modularization by inheritance

Rodja Trappe il y a 1 an
Parent
commit
8e864f4baa

+ 3 - 2
examples/modularization/example_c.py

@@ -1,4 +1,5 @@
 import theme
+from message import message
 
 from nicegui import APIRouter, ui
 
@@ -8,7 +9,7 @@ router = APIRouter(prefix='/c')
 @router.page('/')
 def example_page():
     with theme.frame('- Example C -'):
-        ui.label('Example C').classes('text-h4 text-grey-8')
+        message('Example C')
         for i in range(1, 4):
             ui.link(f'Item {i}', f'/c/items/{i}').classes('text-xl text-grey-8')
 
@@ -16,5 +17,5 @@ def example_page():
 @router.page('/items/{id}', dark=True)
 def item(id: str):
     with theme.frame(f'- Example C{id} -'):
-        ui.label(f'Item  #{id}').classes('text-h4 text-grey-8')
+        message(f'Item  #{id}')
         ui.link('go back', router.prefix).classes('text-xl text-grey-8')

+ 3 - 2
examples/modularization/example_pages.py

@@ -1,4 +1,5 @@
 import theme
+from message import message
 
 from nicegui import ui
 
@@ -8,9 +9,9 @@ def create() -> None:
     @ui.page('/a')
     def example_page_a():
         with theme.frame('- Example A -'):
-            ui.label('Example A').classes('text-h4 text-grey-8')
+            message('Example A')
 
     @ui.page('/b')
     def example_page_b():
         with theme.frame('- Example B -'):
-            ui.label('Example B').classes('text-h4 text-grey-8')
+            message('Example B')

+ 3 - 1
examples/modularization/home_page.py

@@ -1,5 +1,7 @@
+from message import message
+
 from nicegui import ui
 
 
 def content() -> None:
-    ui.label('This is the home page.').classes('text-h4 font-bold text-grey-8')
+    message('This is the home page.').classes('font-bold')

+ 8 - 0
examples/modularization/message.py

@@ -0,0 +1,8 @@
+from nicegui import ui
+
+
+class message(ui.label):
+
+    def __init__(self, text: str):
+        super().__init__(text)
+        self.classes('text-h4 text-grey-8')