# streamlitGUI **Repository Path**: hillmountain/streamlitGUI ## Basic Information - **Project Name**: streamlitGUI - **Description**: 基于streamlit的快速软件开发框架,由西安交通大学网络化智造与服务系统工程团队开发。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 1 - **Created**: 2024-05-22 - **Last Updated**: 2025-09-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Streamlit快速开发框架 本框架搭建了基于Streamlit的快速开发框架,使用者可以通过一键安装所有streamlit常用的第三方库和python库,来快速搭建自己的项目。同时该项目使用了congponents.py文件封装了部分函数,使用者可快速进行调用,避免重复开发。 ## 安装相应库包 通过以下命令安装依赖的库包。.\ 注意:在通过pip install -r requirements.txt进行全部依赖库包安装之前,可检查是否需要所有的库包,不需要的可以注释掉。 ```bash pip install -r requirements.txt ``` ## 依赖环境 系统依赖python和streamlit进行开发: `python` `streamlit` ## components.py封装函数介绍 ```bash # 侧边栏主页,参数(logo,标题,选项标题,展示页标题,作者,开发日期) def layout_sidebar(image, title, header, subheader, choices, autor, date): # 页面菜单,参数(选项数组,选项图表(可为空)) def menu_setting(options, icons=None): ... return selected2 st.write(selected) # 代码展示,参数(代码文件如.py文件) def code_show(input_code=None): # 知识图谱,参数(标题,json文件) def draw_graph(title, input_json): # 基础统计图(柱状图/折线图/饼图/箱盒图/雷达图),参数(标题,标签数组,横坐标数据,纵坐标数据) def stack_bar(title, legend, x_data, y_datas): # 3D模型查看,obj/stl/vtk等,参数(模型保存路径) def show_3D(path): # 图片查看和剪裁,参数(标题) def image_cropping(title): # 表格绘制,参数(标题,excle文件路径) def draw_table(title, path): # 将matplotlib图形转换为图像数据 def fig_to_image(fig): return buf st.image(buf) # 进度条,参数(标题,总时长,间隔时长) def progress_bar(message, total_time, sleep_time): # PDF读取,参数(pdf文件) def view_pdf(pdf_file): ``` ## 所安装的Streamlit第三方库包 | 库包 | 简介 | |---------------------------------------------------------------------------------------------------------| ---- | | [streamlit_echarts](https://github.com/andfanilo/streamlit-echarts) | 可以直接使用Streamlit通过echarts语句设置各种图形(基础图,关系图等)| | [streamlit_option_menu](https://github.com/victoryhb/streamlit-option-menu) | 比较优雅、便捷的导航栏设置| | [streamlit_cropper](https://github.com/turner-Anderson/streamlit-cropper) | 图片剪切库| | [streamlit-pydantic](https://github.com/lukasmasuch/streamlit-pydantic) | 低代码的信息采集| | [streamlit-extras](https://github.com/arnaudmiribel/streamlit-extras) | 40+小功能低代码实现| | [streamlit-chat](https://github.com/AI-Yash/st-chat) | 低代码的聊天界面实现| | [streamlit-elements==0.1.*](https://github.com/okld/streamlit-elements) | 自由度高的页面容器设置库| | [streamlit-authenticator](https://github.com/mkhorasani/Streamlit-Authenticator) | 低代码为streamlit实现的权限控制,登入登出| | [st-pages](https://github.com/blackary/st_pages) | 低代码的多页面控制,便捷实现页面跳转| | [streamlit-shap](https://github.com/snehankekre/streamlit-shap) | 整合SHAP库,实现深度学习可解释分析| | [streamlit_code_editor](https://github.com/bouzidanas/streamlit-code-editor/tree/master) | streamlit适配的代码展示库| | [streamlit-pandas](https://github.com/wjbmattingly/streamlit-pandas) | 加载Pandas DataFrame,并在侧边栏生成过滤事件| | [mitosheet](https://docs.trymito.io/mito-for-streamlit/api-reference) | 有streamlit模块的表格处理库| | [stpyvista](https://discuss.streamlit.io/t/stpyvista-show-pyvista-3d-visualizations-in-streamlit/31802) |pyvista库的streamlit适配版,可进行3D模型操作和展示| | [stqdm](https://github.com/Wirg/stqdm) | 低代码的进度条展示| | [NLU](https://github.com/JohnSnowLabs/nlu) | 低代码的自然语言处理库,整合1000+预训练的模型| | [barfi](https://github.com/krish-adi/barfi) | 流程图| | [hydralit_components](https://github.com/TangleSpace/hydralit_components) | Streamlit第三方组件库,包含导航,标签等,比较美观| ## 所安装的python库包 | 库包 | 简介 | | ---- | ---- | | numpy | 科学计算 | | pandas | 数据结构和数据分析 | | scipy | 用于数学,科学和工程的 | | scikit-learn | SciPy 构建的机器学习模块 | | keras | 以 tensorflow/theano/CNTK 为后端的深度学习封装库 | | pytorch | 深度学习框架 | | tensorflow | 深度学习框架 | | matplotlib | Python 2D 绘图库 | | openpyxl | 读写 Excel 2010 xlsx/xlsm/xltx/xltm | | PyPDF2 | 分割,合并和转换 PDF 页面 | | PIL | 图像归档和图像处理 | ## 应用示例 主程序代码main.py,注意需要与components.py放在同级目录下 ```bash from components import * def on_change(key): selection = st.session_state[key] st.write(f"Selection changed to {selection}") # 侧边栏 choices = ['开发报告', '首页', '结果解释', '代码查看'] choices = layout_sidebar('./xjtu-logo.png', 'streamlit组件测试系统', '运行控制', '信息显示', choices, 'autor', '2024-05-07') # 主页横向menu selected = menu_setting(["首页", "第一页", "第二页"]) st.write(selected) # 代码展示,直接读取文件 code_show("./graph_example.py") # 知识图谱,上传json文件 draw_graph("知识图谱", "./les-miserables.json") # Echarts绘图 x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] y_data = [820, 932, 901, 934, 1290, 1330, 1320] s_line_legend = ["邮件营销", "联盟广告", "视频广告", "直接访问", "搜索引擎"] s_bar_legend = ["Direct", "Mail Ad", "Affiliate Ad", "Video Ad", "Search Engine"] y_datas = [[120, 132, 101, 134, 90, 230, 210], [220, 182, 191, 234, 290, 330, 310], [150, 232, 201, 154, 190, 330, 410], [320, 332, 301, 334, 390, 330, 320], [820, 932, 901, 934, 1290, 1330, 1320]] bar_data = [1048, 735, 580, 484, 300] boxplot_data = [ [850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000, 1000, 960, 960], [960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790, 810, 880, 880, 830, 800, 790, 760, 800], [880, 880, 880, 860, 720, 720, 620, 860, 970, 950, 880, 910, 850, 870, 840, 840, 850, 840, 840, 840], [890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920, 890, 860, 880, 720, 840, 850, 850, 780], [890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870, 810, 740, 810, 940, 950, 800, 810, 870], ] radar_legend = ["预算", "实际"] radar = ["销售", "管理", "信息技术", "客服", "研发", "市场"] radar_data = [[6500, 16000, 30000, 38000, 52000, 25000], [4200, 3000, 20000, 35000, 50000, 18000], [5000, 14000, 28000, 26000, 42000, 21000]] basic_line("单折线图", x_data, y_data) stacked_line("堆叠折线图", s_line_legend, x_data, y_datas) basic_bar("基础柱状图", x_data, y_data) stack_bar("堆叠柱状图", s_bar_legend, x_data, y_datas) simple_pie("基础pie图", "小试牛刀", s_line_legend, bar_data) basic_boxplot("基础箱盒图", "数值", boxplot_data) basic_radar("基础雷达图", radar_legend, radar, radar_data) # 3D展示,obj/stl/vtk等 show_3D('./example_data/bunny.obj') # 图形编辑 image_cropping("cropper Demo") # 表格绘制 draw_table('表格展示', './time_domain_feature.xlsx') # PDF查阅 # view_pdf('./要展示的PDF.pdf') # 进度条 progress_bar("模型训练中,请稍等....", 20, 0.5) ``` # 效果展示 侧边栏、导航栏和代码展示



