快速搭建web见面

Falko Schindler e870878e52 joystick: pass options to nipple 4 vuotta sitten
.github 1d64f44a4b simpler name 4 vuotta sitten
.vscode 852faab6b1 do not set blank lines 4 vuotta sitten
nicegui e870878e52 joystick: pass options to nipple 4 vuotta sitten
sceenshots 02e770f4c1 adding docs for some interactive elements 4 vuotta sitten
.gitignore 11844e40cc cleanup 4 vuotta sitten
LICENSE 0cb68ea25c Adding license 4 vuotta sitten
README.md a5b67cdedf link to explenation about streamlit 4 vuotta sitten
custom_test.py e870878e52 joystick: pass options to nipple 4 vuotta sitten
development.dockerfile 606836f3ed do not remove cache for devel container 4 vuotta sitten
docker-compose.yml 86d41f037e setup a proxy to test hosting on a sub-path; here localhost:8080/app 4 vuotta sitten
docker.sh 627296fbd6 simplified docker.sh 4 vuotta sitten
examples.py 4c65abacfa refactoring of design concept (consistent use of builder pattern for style, classes and props) 4 vuotta sitten
main.py 8bb51a5be8 adding info about styles-method 4 vuotta sitten
nicegui.code-workspace d4d1b6a77b fixed syntax 4 vuotta sitten
poetry.lock ca145254d4 asttokens are a release requirement 4 vuotta sitten
pyproject.toml ca145254d4 asttokens are a release requirement 4 vuotta sitten
release.dockerfile 477a2e7e58 now we use our own template instead of patching justpy 4 vuotta sitten

README.md

NiceGUI

We like Streamlit but find it does too much magic when it comes to state handling. In search for an alernative 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".

Purpose

NiceGUI is intended to be used for small scripts and single-page user interfaces with a very limited user base. Like smart home solutions, micro web apps or robotics projects. It's also helpful for development, when tweaking/configuring a machine learning training or tuning motor controllers.

Features

  • browser-based graphical user interface
  • shared state between multiple browser windows
  • implicit reload on code change
  • clean set of GUI elements (label, button, checkbox, switch, slider, input, ...)
  • simple grouping with rows, columns and cards
  • general-purpose HTML and markdown elements
  • built-in timer to refresh data in intervals (even every 10 ms)
  • straight-forward data binding to write even less code

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))

Launch it with:

python3 main.py

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

Docker

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

docker run --rm -p 8888:80 -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.

API

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