赞
踩
发现一个方便写webui的库nicegui,闲来就试一试。方便数据展示,做个数据大屏。
NiceGUI是一个简单易用的基于Python的Web-UI框架,其目的是使在Python中开发前端应用程序变得容易。
NiceGUI基于FastAPI,封装了Quasar、Vue、Tailwind CSS、AG Grid、ECharts等,可以用来快速开发web或桌面程序。
NiceGUI官网:https://nicegui.io/
使用是不是很简单!
NiceGUI 可以轻松展示 Pandas DataFrame,我们就使用 table() 函数本身可以显示 Pandas 数据。
【行情采集】解析JS 1秒获取5000支股票瞬时行情(送代码,含筛选方法)https://blog.csdn.net/popboy29/article/details/127467048
代码如下(示例):
from nicegui import ui
df_data = get_stocklist_dfcfw()['df_data']# 函数来自上面的文章
df = df_data.copy()[(df_data['volume']>0) & (df_data['zhangfu']>9.9)].sort_values(by = 'zhangfu',ascending=False)
columns = {'close':'最新价','zhangfu':'涨幅%','zhangdie':'涨跌','volume':'成交量','amount':'成交额','zhenfu':'振幅%','hs_l':'换手率','pe_d':'动态PE','liangbi':'量比','code':'代码','name':'名称','high':'最高价','low':'最低价','open':'开盘价','pre_close':'昨收','z_value':'总市值','lt_value':'流通市值','sj_l':'市净率'}
df = df.copy().rename(index=str, columns=columns)
cols = ['代码','名称','昨收','最新价','涨幅%','涨跌','振幅%','开盘价','最高价','最低价','成交量','成交额','量比','换手率','总市值','流通市值','动态PE','市净率']
df = df[cols]
# print(df)
ui.label('检索当日股票涨幅大于9.9的股票')
ui.table(
columns=[{'name': column, 'label': column, 'field': column} for column in df.columns],
rows=df.to_dict('records'),
)
ui.run()
NiceGUI 还有很多用法,具体大家可以访问:https://nicegui.io/。
nicegui安装记录,建议独立使用虚拟环境安装。
(base) C:\Users\Administrator>pip install nicegui -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting nicegui
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/44/b3/499a0f3de38de999e81c46a9536a9de6bc12b12bc10ca1d908c40206a506/nicegui-1.4.9-py3-none-any.whl (14.7 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 14.7/14.7 MB 28.5 MB/s eta 0:00:00
Requirement already satisfied: Pygments<3.0.0,>=2.15.1 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (2.15.1)
Requirement already satisfied: aiofiles<24.0.0,>=23.1.0 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (23.1.0)
Collecting fastapi<1.0.0,>=0.108.0 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e5/80/ddbf524c6169072ab5e8dd4e106d4eb482bf920da1996dde9f308f90aa8c/fastapi-0.109.0-py3-none-any.whl (92 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 92.0/92.0 kB 2.6 MB/s eta 0:00:00
Collecting fastapi-socketio<0.0.11,>=0.0.10 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b5/49/50fe1f72b10c1902fc057e5810f51bffc94c5cab416cf9f16358e71b021a/fastapi_socketio-0.0.10-py3-none-any.whl (7.4 kB)
Collecting httpx<1.0.0,>=0.24.0 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/39/9b/4937d841aee9c2c8102d9a4eeb800c7dad25386caabb4a1bf5010df81a57/httpx-0.26.0-py3-none-any.whl (75 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.9/75.9 kB 4.1 MB/s eta 0:00:00
Collecting ifaddr<0.3.0,>=0.2.0 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/1f/19ebc343cc71a7ffa78f17018535adc5cbdd87afb31d7c34874680148b32/ifaddr-0.2.0-py3-none-any.whl (12 kB)
Collecting itsdangerous<3.0.0,>=2.1.2 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/68/5f/447e04e828f47465eeab35b5d408b7ebaaaee207f48b7136c5a7267a30ae/itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Requirement already satisfied: jinja2<4.0.0,>=3.1.2 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (3.1.2)Collecting markdown2<2.4.11,>=2.4.7 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f1/98/61276a753f078dd2f3171c9a69fd3f451d220e806b2b1cdca41b8e368b0f/markdown2-2.4.10-py2.py3-none-any.whl (39 kB)
Requirement already satisfied: orjson<4.0.0,>=3.8.6 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (3.8.7)Requirement already satisfied: python-multipart<0.0.7,>=0.0.6 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (0.0.6)
Collecting python-socketio>=5.10.0 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5c/6d/dd2447d27979c4ca84738bb4d5a9245aa8e1f736b4054d894f7fd2030c84/python_socketio-5.11.0-py3-none-any.whl (75 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 75.4/75.4 kB 2.1 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions>=4.0.0 in d:\programdata\anaconda3\lib\site-packages (from nicegui) (4.4.0)
Collecting uvicorn>=0.22.0 (from uvicorn[standard]>=0.22.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/26/59/fddd9df489fe27f492cc97626e03663fb3b9b6ef7ce8597a7cdc5f2cbbad/uvicorn-0.25.0-py3-none-any.whl (60 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.3/60.3 kB 1.6 MB/s eta 0:00:00
Collecting vbuild>=0.8.2 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/3d/7b22abbdb059d551507275a2815bc2b1974e3b9f6a13781c1eac9e858965/vbuild-0.8.2-py2.py3-none-any.whl (9.4 kB)
Collecting watchfiles<1.0.0,>=0.18.1 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4b/ea/80527adf1ad51488a96fc201715730af5879f4dfeccb5e2069ff82d890d4/watchfiles-0.21.0-cp310-none-win_amd64.whl (279 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 279.7/279.7 kB 5.7 MB/s eta 0:00:00
Requirement already satisfied: pydantic!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4 in d:\programdata\anaconda3\lib\site-packages (from fastapi<1.0.0,>=0.108.0->nicegui) (1.10.6)
Collecting starlette<0.36.0,>=0.35.0 (from fastapi<1.0.0,>=0.108.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/03/13/c60c738da2fb69d60ee1dc5631e8d152352003cc0bc4ce39582bdd90e293/starlette-0.35.1-py3-none-any.whl (71 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.1/71.1 kB 2.0 MB/s eta 0:00:00
Collecting typing-extensions>=4.0.0 (from nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b7/f4/6a90020cd2d93349b442bfcb657d0dc91eee65491600b2cb1d388bc98e6b/typing_extensions-4.9.0-py3-none-any.whl (32 kB)
Requirement already satisfied: anyio in d:\programdata\anaconda3\lib\site-packages (from httpx<1.0.0,>=0.24.0->nicegui) (3.5.0)
Requirement already satisfied: certifi in d:\programdata\anaconda3\lib\site-packages (from httpx<1.0.0,>=0.24.0->nicegui) (2022.12.7)
Collecting httpcore==1.* (from httpx<1.0.0,>=0.24.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/56/ba/78b0a99c4da0ff8b0f59defa2f13ca4668189b134bd9840b6202a93d9a0f/httpcore-1.0.2-py3-none-any.whl (76 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 76.9/76.9 kB 2.2 MB/s eta 0:00:00
Requirement already satisfied: idna in d:\programdata\anaconda3\lib\site-packages (from httpx<1.0.0,>=0.24.0->nicegui) (3.4)
Requirement already satisfied: sniffio in d:\programdata\anaconda3\lib\site-packages (from httpx<1.0.0,>=0.24.0->nicegui) (1.2.0)
Requirement already satisfied: h11<0.15,>=0.13 in d:\programdata\anaconda3\lib\site-packages (from httpcore==1.*->httpx<1.0.0,>=0.24.0->nicegui) (0.14.0)
Requirement already satisfied: MarkupSafe>=2.0 in d:\programdata\anaconda3\lib\site-packages (from jinja2<4.0.0,>=3.1.2->nicegui) (2.1.1)
Collecting bidict>=0.21.0 (from python-socketio>=5.10.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b5/82/ce0b6380f35f49d3fe687979a324c342cfa3588380232f3801db9dd62f9e/bidict-0.22.1-py3-none-any.whl (35 kB)
Collecting python-engineio>=4.8.0 (from python-socketio>=5.10.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/ca/b14136484c9a10230abbf44a89041ccd2c696d0cb425e53f48ca0de0d1e7/python_engineio-4.8.2-py3-none-any.whl (57 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 57.4/57.4 kB 3.1 MB/s eta 0:00:00
Requirement already satisfied: click>=7.0 in d:\programdata\anaconda3\lib\site-packages (from uvicorn>=0.22.0->uvicorn[standard]>=0.22.0->nicegui) (8.1.3)
Requirement already satisfied: colorama>=0.4 in d:\programdata\anaconda3\lib\site-packages (from uvicorn[standard]>=0.22.0->nicegui) (0.4.6)
Collecting httptools>=0.5.0 (from uvicorn[standard]>=0.22.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1e/fc/8a26c2adcd3f141e4729897633f03832b71ebea6f4c31cce67a92ded1961/httptools-0.6.1-cp310-cp310-win_amd64.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.2/58.2 kB 3.0 MB/s eta 0:00:00
Requirement already satisfied: python-dotenv>=0.13 in d:\programdata\anaconda3\lib\site-packages (from uvicorn[standard]>=0.22.0->nicegui) (1.0.0)
Requirement already satisfied: pyyaml>=5.1 in d:\programdata\anaconda3\lib\site-packages (from uvicorn[standard]>=0.22.0->nicegui) (6.0)
Requirement already satisfied: websockets>=10.4 in d:\programdata\anaconda3\lib\site-packages (from uvicorn[standard]>=0.22.0->nicegui) (10.4)
Collecting pscript<0.8.0,>=0.7.0 (from vbuild>=0.8.2->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f1/bc/980e2ebd442d2a8f1d22780f73db76f2a1df3bf79b3fb501b054b4b4dd03/pscript-0.7.7-py3-none-any.whl (126 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 126.7/126.7 kB 2.5 MB/s eta 0:00:00
Collecting simple-websocket>=0.10.0 (from python-engineio>=4.8.0->python-socketio>=5.10.0->nicegui)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6d/ea/288a8ac1d9551354488ff60c0ac6a76acc3b6b60f0460ac1944c75e240da/simple_websocket-1.0.0-py3-none-any.whl (13 kB)
Requirement already satisfied: wsproto in d:\programdata\anaconda3\lib\site-packages (from simple-websocket>=0.10.0->python-engineio>=4.8.0->python-socketio>=5.10.0->nicegui) (1.2.0)
Installing collected packages: pscript, ifaddr, vbuild, typing-extensions, markdown2, itsdangerous, httptools, httpcore, bidict, watchfiles, uvicorn, starlette, simple-websocket, httpx, python-engineio, fastapi, python-socketio, fastapi-socketio, nicegui
Attempting uninstall: typing-extensions
Found existing installation: typing_extensions 4.4.0
Uninstalling typing_extensions-4.4.0:
Successfully uninstalled typing_extensions-4.4.0
Attempting uninstall: itsdangerous
Found existing installation: itsdangerous 2.0.1
Uninstalling itsdangerous-2.0.1:
Successfully uninstalled itsdangerous-2.0.1
Attempting uninstall: httpcore
Found existing installation: httpcore 0.16.3
Uninstalling httpcore-0.16.3:
Successfully uninstalled httpcore-0.16.3
Attempting uninstall: uvicorn
Found existing installation: uvicorn 0.21.1
Uninstalling uvicorn-0.21.1:
Successfully uninstalled uvicorn-0.21.1
Attempting uninstall: starlette
Found existing installation: starlette 0.26.1
Uninstalling starlette-0.26.1:
Successfully uninstalled starlette-0.26.1
Attempting uninstall: httpx
Found existing installation: httpx 0.23.3
Uninstalling httpx-0.23.3:
Successfully uninstalled httpx-0.23.3
Attempting uninstall: fastapi
Found existing installation: fastapi 0.95.0
Uninstalling fastapi-0.95.0:
Successfully uninstalled fastapi-0.95.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
openapi-python-client 0.13.4 requires httpx<0.25.0,>=0.15.4, but you have httpx 0.26.0 which is incompatible.
Successfully installed bidict-0.22.1 fastapi-0.109.0 fastapi-socketio-0.0.10 httpcore-1.0.2 httptools-0.6.1 httpx-0.26.0 ifaddr-0.2.0 itsdangerous-2.1.2 markdown2-2.4.10 nicegui-1.4.9 pscript-0.7.7 python-engineio-4.8.2 python-socketio-5.11.0 simple-websocket-1.0.0 starlette-0.35.1 typing-extensions-4.9.0 uvicorn-0.25.0 vbuild-0.8.2 watchfiles-0.21.0
(base) C:\Users\Administrator>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。