Skip to content

Add env variable to use native versus browser tab in nicegui main.py #6

@cudmore

Description

@cudmore

Goal:

I would like an option to use an embedded browser tab (native=False) versus native mode (native=True) in nicegui

Current status

Right now our main.py is using an environment variable to determine if we ui.run() nicegui with reload of True/False.

We do that with something like this:

default_reload = not is_frozen and os.getenv("KYMFLOW_GUI_RELOAD", "1") == "1"

I want to add a feature to toggle native True/False in a similar way.

Proposed plan

I would like to do the same for an option to show native with True/False.

Right now we have this:

    _native = False  # when True, runs in native window (Mac only)
    # reload = False
    ui.run(
        port=DEFAULT_PORT, reload=reload, native=_native, storage_secret=STORAGE_SECRET
    )

Using an environment variable is fine.

I would like it to default to native=False for debugging

When we build the app in a github workflow I would like to always use native=True.

Looking at our github workflow that builds the app in release.yml, we have this

      - name: Build macOS app with nicegui-pack
        env:
          KYMFLOW_GUI_RELOAD: "0"
        run: |
          nicegui-pack \
            --windowed \
            --name "KymFlow" \
            --icon "pyinstaller/macos/kymflow.icns" \
            src/kymflow_gui/main.py

I guess the solution would expand this to use something like

KYMFLOW_GUI_NATIVE: "1"

Conclusion

Let me know what you think. Do not guess and ask for clarification. Make changes minimal. We are basically adding an environment variable to toggle nicegui ui.run native option to True/False.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions