瀏覽代碼

- 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 example(ui.open):
     with ui.page('/yet_another_page') as other:
     with ui.page('/yet_another_page') as other:
         ui.label('Welcome to yet another page')
         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)
 ui.run(port=8080)

+ 3 - 0
nicegui/elements/open.py

@@ -9,6 +9,9 @@ class Open:
         Open
         Open
 
 
         Can be used to programmatically trigger redirects for a specific client.
         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))
         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
 import traceback
 from typing import Any, Awaitable, Callable, List, Optional, Union
 from typing import Any, Awaitable, Callable, List, Optional, Union
 from starlette.websockets import WebSocket
 from starlette.websockets import WebSocket
+
 from .elements.element import Element
 from .elements.element import Element
 from .task_logger import create_task
 from .task_logger import create_task