快速搭建web见面

Rodja Trappe 9e4018b49f upgraded dependend packages to the latest version há 3 anos atrás
.github a109b99120 better naming há 3 anos atrás
.vscode 3ed9b0804f adding jinja-html vscode extension há 4 anos atrás
nicegui bf4380a0d7 Merge branch 'main' into feature/anchorlinks há 3 anos atrás
sceenshots 02e770f4c1 adding docs for some interactive elements há 4 anos atrás
.gitignore c171747c8e Notification element há 3 anos atrás
LICENSE 0cb68ea25c Adding license há 4 anos atrás
README.md 80eee3be19 review há 3 anos atrás
custom_test.py aaf0b672da remove three element há 4 anos atrás
development.dockerfile 68fa244564 making sure we support python 3.7 há 3 anos atrás
docker-compose.yml e5a062aaa9 cleanup há 3 anos atrás
docker.sh f6a2e09c06 run command is not needed há 3 anos atrás
examples.py 95127e72d7 new binding implementation (no code inspection, no cursing) há 3 anos atrás
main.py f79f674353 using lower case headline achors há 3 anos atrás
nicegui.code-workspace d653e0d86b Remove bindings to/from justpy elements which are already deleted há 3 anos atrás
poetry.lock 9e4018b49f upgraded dependend packages to the latest version há 3 anos atrás
pyproject.toml fc408a9737 Fixe installation issues há 3 anos atrás
release.dockerfile 477a2e7e58 now we use our own template instead of patching justpy há 4 anos atrás
setup.py ff08954e1a Increases version to 1.0 for local installations há 3 anos atrás
test_startup.sh 4f17c92432 increased timeout to maybe fix the tests há 3 anos atrás

README.md

NiceGUI

NiceGUI is an easy-to-use, Python-based UI framework, which renders to the web browser. You can create buttons, dialogs, markdown, 3D scenes, plots and much more.

It was designed to be used for micro web apps, dashboards, robotics projects, smart home solutions and similar use cases. It is also helpful for development, for example when tweaking/configuring a machine learning algorithm or tuning motor controllers.

Features

  • browser-based graphical user interface
  • shared state between multiple browser windows
  • implicit reload on code change
  • standard GUI elements like label, button, checkbox, switch, slider, input, file upload, ...
  • simple grouping with rows, columns, cards and dialogs
  • general-purpose HTML and markdown elements
  • powerful elements to plot graphs, render 3D scenes and get steering events via virtual joysticks
  • built-in timer to refresh data in intervals (even every 10 ms)
  • straight-forward data binding to write even less code
  • notifications, dialogs and menus to provide state of the art user interaction

Installation

python3 -m pip install nicegui

Usage

Write your nice GUI in a file main.py:

from nicegui import ui

ui.label('Hello NiceGUI!')
ui.button('BUTTON', on_click=lambda: print('button was pressed', flush=True))

ui.run()

Launch it with:

python3 main.py

The GUI is now available through http://localhost:8080/ in your browser. Note: The script will automatically reload the page when you modify the code.

Full documentation can be found at https://nicegui.io.

Configuration

You can call ui.run() with optional arguments for some high-level configuration:

  • host (default: '0.0.0.0')
  • port (default: 8080)
  • title (default: 'NiceGUI')
  • favicon (default: 'favicon.ico')
  • reload: automatically reload the ui on file changes (default: True)
  • show: automatically open the ui in a browser tab (default: True)
  • uvicorn_logging_level: logging level for uvicorn server (default: 'warning')
  • interactive: used internally when run in interactive Python shell (default: False)

Docker

Use the multi-arch docker image for pain-free installation:

docker run --rm -p 8888:8080 -v $(pwd)/my_script.py:/app/main.py -it zauberzeug/nicegui:latest

This will start the server at http://localhost:8888 with code from my_script.py within the current directory. Code modification triggers an automatic reload.

Why?

We like Streamlit but find it does too much magic when it comes to state handling. In search for an alternative nice library to write simple graphical user interfaces in Python we discovered justpy. While too "low-level HTML" for our daily usage it provides a great basis for "NiceGUI".

API

The API reference is hosted at https://nicegui.io and is implemented with NiceGUI itself. You may also have a look at examples.py for more demonstrations of what you can do with NiceGUI.