1
0
Эх сурвалжийг харах

restore native mode and splitter documentation

Falko Schindler 2 жил өмнө
parent
commit
6b4a93d07b
1 өөрчлөгдсөн 32 нэмэгдсэн , 6 устгасан
  1. 32 6
      website/documentation.py

+ 32 - 6
website/documentation.py

@@ -2,7 +2,7 @@ import uuid
 
 from nicegui import app, ui
 
-from .demo import bash_window, python_window
+from . import demo
 from .documentation_tools import element_demo, heading, intro_demo, load_demo, subheading, text_demo
 
 CONSTANT_UUID = str(uuid.uuid4())
@@ -163,6 +163,7 @@ def create_full() -> None:
         ui.button('Clear', on_click=container.clear)
 
     load_demo(ui.expansion)
+    load_demo(ui.splitter)
 
     @text_demo('Tabs', '''
         The elements `ui.tabs`, `ui.tab`, `ui.tab_panels`, and `ui.tab_panel` resemble
@@ -569,6 +570,7 @@ def create_full() -> None:
             ui.input('G').classes('w-12').on('keydown.space', lambda: ui.notify('You pressed space.'))
             ui.input('H').classes('w-12').on('keydown.y.shift', lambda: ui.notify('You pressed Shift+Y'))
             ui.input('I').classes('w-12').on('keydown.once', lambda: ui.notify('You started typing.'))
+
     heading('Configuration')
 
     @element_demo(ui.run, browser_title='My App')
@@ -577,6 +579,30 @@ def create_full() -> None:
 
         # ui.run(title='My App')
 
+    # HACK: switch color to white for the next demo
+    demo_BROWSER_BGCOLOR = demo.BROWSER_BGCOLOR
+    demo.BROWSER_BGCOLOR = '#ffffff'
+
+    @text_demo('Native Mode', '''
+        You can enable native mode for NiceGUI by specifying `native=True` in the `ui.run` function. 
+        To customize the initial window size and display mode, use the `window_size` and `fullscreen` parameters respectively. 
+        Additionally, you can provide extra keyword arguments via `app.native.window_args` and `app.native.start_args`.
+        Pick any parameter as it is defined by the internally used [pywebview module](https://pywebview.flowrl.com/guide/api.html) 
+        for the `webview.create_window` and `webview.start` functions.
+        Note that these keyword arguments will take precedence over the parameters defined in ui.run.
+    ''')
+    def native_mode_demo():
+        from nicegui import app
+
+        ui.label('app running in native mode')
+
+        app.native.window_args['resizable'] = False
+        app.native.start_args['debug'] = True
+
+        # ui.run(native=True, window_size=(400, 300), fullscreen=False)
+    # HACK: restore color
+    demo.BROWSER_BGCOLOR = demo_BROWSER_BGCOLOR
+
     @text_demo('Environment Variables', '''
         You can set the following environment variables to configure NiceGUI:
 
@@ -601,7 +627,7 @@ def create_full() -> None:
         A convenient alternative is the use of our [pre-built multi-arch Docker image](https://hub.docker.com/r/zauberzeug/nicegui) which contains all necessary dependencies.
         With this command you can launch the script `main.py` in the current directory on the public port 80:
     ''').classes('bold-links arrow-links')
-    with bash_window(classes='max-w-lg w-full h-52'):
+    with demo.bash_window(classes='max-w-lg w-full h-52'):
         ui.markdown('''
             ```bash
             docker run -p 80:8080 -v $(pwd)/:/app/ \\
@@ -613,7 +639,7 @@ def create_full() -> None:
         The `-d` tells docker to run in background and `--restart always` makes sure the container is restarted if the app crashes or the server reboots.
         Of course this can also be written in a Docker compose file:
     ''')
-    with python_window('docker-compose.yml', classes='max-w-lg w-full h-52'):
+    with demo.python_window('docker-compose.yml', classes='max-w-lg w-full h-52'):
         ui.markdown('''
             ```yaml
             app:
@@ -647,7 +673,7 @@ def create_full() -> None:
     ''').classes('bold-links arrow-links')
 
     with ui.row().classes('w-full items-stretch'):
-        with python_window(classes='max-w-lg w-full'):
+        with demo.python_window(classes='max-w-lg w-full'):
             ui.markdown('''
                 ```python
                 from nicegui import ui
@@ -657,7 +683,7 @@ def create_full() -> None:
                 ui.run(reload=False)
                 ```
             ''')
-        with python_window('build.py', classes='max-w-lg w-full'):
+        with demo.python_window('build.py', classes='max-w-lg w-full'):
             ui.markdown('''
                 ```python
                 import os
@@ -719,7 +745,7 @@ def create_full() -> None:
           That is why the build script invokes PyInstaller using `python -m PyInstaller` rather than just `pyinstaller`.
     ''').classes('bold-links arrow-links')
 
-    with bash_window(classes='max-w-lg w-full h-42 self-center'):
+    with demo.bash_window(classes='max-w-lg w-full h-42 self-center'):
         ui.markdown('''
             ```bash
             python -m venv venv