快速搭建web见面

Rodja Trappe 2a15db99d5 Merge branch 'main' of github.com:zauberzeug/nicegui into main %!s(int64=4) %!d(string=hai) anos
.github fc127dc4fe trying to make automated pypi releases with poetry %!s(int64=4) %!d(string=hai) anos
.vscode 852faab6b1 do not set blank lines %!s(int64=4) %!d(string=hai) anos
nicegui 518732d900 more flexible design arguments %!s(int64=4) %!d(string=hai) anos
sceenshots 2b3acf9381 smaller screenshot %!s(int64=4) %!d(string=hai) anos
.gitignore 11844e40cc cleanup %!s(int64=4) %!d(string=hai) anos
Dockerfile e11050e6f3 made dev container debuggable %!s(int64=4) %!d(string=hai) anos
README.md 4cb4cba0d3 using absolute image path to fix appearance on Pypi %!s(int64=4) %!d(string=hai) anos
docker-compose.yml 72d4c24e8b do not show reloading popups %!s(int64=4) %!d(string=hai) anos
docker.sh 627296fbd6 simplified docker.sh %!s(int64=4) %!d(string=hai) anos
main.py 2a15db99d5 Merge branch 'main' of github.com:zauberzeug/nicegui into main %!s(int64=4) %!d(string=hai) anos
nicegui.code-workspace e11050e6f3 made dev container debuggable %!s(int64=4) %!d(string=hai) anos
poetry.lock 125e7db7c5 fixing dependencies and cleaner Dockerfile %!s(int64=4) %!d(string=hai) anos
pyproject.toml fd28733c72 fixed syntax %!s(int64=4) %!d(string=hai) anos
setup.py 722462189c renaming from nice_gui to nicegui %!s(int64=4) %!d(string=hai) anos

README.md

NiceGUI

We like Streamlit but find it does to 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 our shot at a "NiceGUI".

Features

  • browser-based GUI
  • implicit reload on code change
  • clean set of GUI elements (label, button, checkbox, switch, slider, input, ...)
  • simple grouping with rows, columns and cards
  • built-in timer to refresh data in intervals (even every 10 ms)
  • straight-forward data bindings to write even less code

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

Launch it with:

python3 main.py

Note: The script will automatically reload the GUI if you modify your code.

API

See main.py for an example of all API calls you can make with NiceGUI.

Plots

lines = ui.line_plot(n=2, limit=20).with_legend(['sin', 'cos'], loc='upper center', ncol=2)
ui.timer(0.1, lambda: lines.push([datetime.now()], [
    [np.sin(datetime.now().timestamp()) + 0.02 * np.random.randn()],
    [np.cos(datetime.now().timestamp()) + 0.02 * np.random.randn()],
]))