Переглянути джерело

- Extends documentation and example

Christoph Trappe 3 роки тому
батько
коміт
f7e89d0e55
3 змінених файлів з 6 додано та 2 видалено
  1. 2 2
      main.py
  2. 3 0
      nicegui/elements/open.py
  3. 1 0
      nicegui/events.py

+ 2 - 2
main.py

@@ -436,8 +436,8 @@ with example(ui.keyboard):
 with example(ui.open):
     with ui.page('/yet_another_page') as other:
         ui.label('Welcome to yet another page')
-        ui.button('BUTTON', on_click=lambda e: ui.open('/', e.socket))
+        ui.button('RETURN', on_click=lambda e: ui.open('/', e.socket))
 
-    ui.button('BUTTON', on_click=lambda e: ui.open('/yet_another_page', e.socket))
+    ui.button('REDIRECT', on_click=lambda e: ui.open('/yet_another_page', e.socket))
 
 ui.run(port=8080)

+ 3 - 0
nicegui/elements/open.py

@@ -9,6 +9,9 @@ class Open:
         Open
 
         Can be used to programmatically trigger redirects for a specific client.
+
+        :param path: string that is a relative url path or an absolute url
+        :param socket: WebSocket defining the target client
         """
         asyncio.get_event_loop().create_task(self.redirect_async(path, socket))
 

+ 1 - 0
nicegui/events.py

@@ -5,6 +5,7 @@ from pydantic import BaseModel
 import traceback
 from typing import Any, Awaitable, Callable, List, Optional, Union
 from starlette.websockets import WebSocket
+
 from .elements.element import Element
 from .task_logger import create_task