Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Web UI: NiceGUI #401

Open
hhstore opened this issue Jun 13, 2023 · 10 comments
Open

Python Web UI: NiceGUI #401

hhstore opened this issue Jun 13, 2023 · 10 comments
Labels
Python python 3.5+ (3.6, 3.7) UI/UE Web

Comments

@hhstore
Copy link
Owner

hhstore commented Jun 13, 2023

related:

  • ✅ xxx
  • ✅ xxx
  • ✅ xxx
  • ✅ xxx
@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

Python Web UI 方案: NiceGUI

官方资源:

依赖项目:

FastAPI

Vue.js 3.x:

Vue UI 框架: Quasar

CSS 样式: Tailwind

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

NiceGUI 踩坑系列:

页面路由:

页面跳转方式:

ui.open()

ui.link()

ui.link('Back to main page', '/documentation#page')

i18n 多语言:

页面移动元素:

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

NiceGUI 常用组件:

配色:

from nicegui import ui

ui.button('Default', on_click=lambda: ui.colors())
ui.button('Gray', on_click=lambda: ui.colors(primary='#555'))

ui.run()
from nicegui import ui

dark = ui.dark_mode()
ui.label('Switch mode:')
ui.button('Dark', on_click=dark.enable)
ui.button('Light', on_click=dark.disable)

ui.run()

Row:

Column:

Grid / AG Grid:

grid:

ag grid:

Chart:

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

🔥️ NiceGUI 高级功能:

Run JavaScript

Parameter injection

UI Updates

Refreshable UI functions

import random
from nicegui import ui

numbers = []

@ui.refreshable
def number_ui() -> None:
    ui.label(', '.join(str(n) for n in sorted(numbers)))

def add_number() -> None:
    numbers.append(random.randint(0, 100))
    number_ui.refresh()

number_ui()
ui.button('Add random number', on_click=add_number)

ui.run()

Bindings

  • ✅️ 自定义组件, 数据绑定

Keyboard

  • ✅️ 按键效果控制, 快捷键等
  • ✅️ Keyboard

Query Selector

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

NiceGUI 组件:

Storage

app.storage.user.get('count', 0) + 1

app.storage.general:

app.storage.browser:

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

NiceGUI 魔法部分:

  • 内部实现的细节 & 原理

Auto-context

  • ✅️ 自动上下文, 可以动态创建组件!!!
  • ✅️ Auto-context

Generic Events

  • ✅️ on 事件监听(vue), 可以给各种组件, 注册事件.
  • ✅️ Generic Events

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

NiceGUI 部署:

打包成 app:

Server + Docker:

docker run -p 80:8080 -v $(pwd)/:/app/ \
    -d --restart always zauberzeug/nicegui:latest

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

FastAPI 相关:

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

Vue + Quasar 相关:

Tailwind CSS 相关:

@hhstore
Copy link
Owner Author

hhstore commented Jun 13, 2023

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python python 3.5+ (3.6, 3.7) UI/UE Web
Projects
None yet
Development

No branches or pull requests

1 participant