Selaa lähdekoodia

move awaitable dialog demo onto the dialog page

Falko Schindler 2 vuotta sitten
vanhempi
säilyke
fbf0f9ee01

+ 0 - 18
website/documentation.py

@@ -201,24 +201,6 @@ def create_full() -> None:
     load_demo(ui.notify)
     load_demo(ui.dialog)
 
-    @text_demo('Awaitable dialog', '''
-        Dialogs can be awaited.
-        Use the `submit` method to close the dialog and return a result.
-        Canceling the dialog by clicking in the background or pressing the escape key yields `None`.
-    ''')
-    def async_dialog_demo():
-        with ui.dialog() as dialog, ui.card():
-            ui.label('Are you sure?')
-            with ui.row():
-                ui.button('Yes', on_click=lambda: dialog.submit('Yes'))
-                ui.button('No', on_click=lambda: dialog.submit('No'))
-
-        async def show():
-            result = await dialog
-            ui.notify(f'You chose {result}')
-
-        ui.button('Await a dialog', on_click=show)
-
     heading('Appearance')
 
     @text_demo('Styling', '''

+ 22 - 0
website/more_documentation/dialog_documentation.py

@@ -1,5 +1,7 @@
 from nicegui import ui
 
+from ..documentation_tools import text_demo
+
 
 def main_demo() -> None:
     with ui.dialog() as dialog, ui.card():
@@ -7,3 +9,23 @@ def main_demo() -> None:
         ui.button('Close', on_click=dialog.close)
 
     ui.button('Open a dialog', on_click=dialog.open)
+
+
+def more() -> None:
+    @text_demo('Awaitable dialog', '''
+        Dialogs can be awaited.
+        Use the `submit` method to close the dialog and return a result.
+        Canceling the dialog by clicking in the background or pressing the escape key yields `None`.
+    ''')
+    def async_dialog_demo():
+        with ui.dialog() as dialog, ui.card():
+            ui.label('Are you sure?')
+            with ui.row():
+                ui.button('Yes', on_click=lambda: dialog.submit('Yes'))
+                ui.button('No', on_click=lambda: dialog.submit('No'))
+
+        async def show():
+            result = await dialog
+            ui.notify(f'You chose {result}')
+
+        ui.button('Await a dialog', on_click=show)

+ 2 - 1
website/more_documentation/video_documentation.py

@@ -1,5 +1,6 @@
 from nicegui import ui
-from website.documentation_tools import text_demo
+
+from ..documentation_tools import text_demo
 
 
 def main_demo() -> None: