浏览代码

update documentation with ui.run()

Falko Schindler 3 年之前
父节点
当前提交
05d0551054
共有 3 个文件被更改,包括 19 次插入0 次删除
  1. 13 0
      README.md
  2. 2 0
      examples.py
  3. 4 0
      main.py

+ 13 - 0
README.md

@@ -38,6 +38,8 @@ from nicegui import ui
 
 
 ui.label('Hello NiceGUI!')
 ui.label('Hello NiceGUI!')
 ui.button('BUTTON', on_click=lambda: print('button was pressed', flush=True))
 ui.button('BUTTON', on_click=lambda: print('button was pressed', flush=True))
+
+ui.run()
 ```
 ```
 
 
 Launch it with:
 Launch it with:
@@ -49,6 +51,17 @@ python3 main.py
 The GUI is now avaliable through http://localhost/ in your browser.
 The GUI is now avaliable through http://localhost/ in your browser.
 Note: The script will automatically reload the page when you modify the code.
 Note: The script will automatically reload the page when you modify the code.
 
 
+## Configuration
+
+You can call `ui.run()` with optional arguments for some high-level configuration:
+
+- `host` (default: `'0.0.0.0'`)
+- `port` (default: `80`)
+- `title` (default: `'NiceGUI'`)
+- `favicon` (default: `'favicon.png'`)
+- `reload`: automatically reload the ui on file changes (default: `True`)
+- `show`: automatically open the ui in a browser tab (default: `True`)
+
 ## Docker
 ## Docker
 
 
 Use the [multi-arch docker image](https://hub.docker.com/repository/docker/zauberzeug/nicegui) for pain-free installation:
 Use the [multi-arch docker image](https://hub.docker.com/repository/docker/zauberzeug/nicegui) for pain-free installation:

+ 2 - 0
examples.py

@@ -91,3 +91,5 @@ with ui.row():
             [np.sin(datetime.now().timestamp()) + 0.02 * np.random.randn()],
             [np.sin(datetime.now().timestamp()) + 0.02 * np.random.randn()],
             [np.cos(datetime.now().timestamp()) + 0.02 * np.random.randn()],
             [np.cos(datetime.now().timestamp()) + 0.02 * np.random.randn()],
         ]))
         ]))
+
+ui.run()

+ 4 - 0
main.py

@@ -42,6 +42,8 @@ def example(content: Union[Element, str]):
         code = [l[4:] for l in code]
         code = [l[4:] for l in code]
         code.insert(0, '```python')
         code.insert(0, '```python')
         code.insert(1, 'from nicegui import ui')
         code.insert(1, 'from nicegui import ui')
+        code.append('')
+        code.append('ui.run()')
         code.append('```')
         code.append('```')
         code = '\n'.join(code)
         code = '\n'.join(code)
         ui.markdown(code).classes('mt-12 w-5/12 overflow-auto')
         ui.markdown(code).classes('mt-12 w-5/12 overflow-auto')
@@ -288,3 +290,5 @@ with example(lifecycle):
             await asyncio.sleep(1)
             await asyncio.sleep(1)
 
 
     ui.on_startup(counter())
     ui.on_startup(counter())
+
+ui.run()