当前位置: 首页 > news >正文

python ui框架

目录

gradio python模块做交互界面很好用

ui拖拽


gradio python模块做交互界面很好用

ui拖拽

import gradio as gr
import os
from datetime import datetimedef process_uploaded_file(files):"""处理上传的文件并返回文件信息"""file_info = []for file in files:if file is None:continue# 获取文件信息file_name = os.path.bas(file.name)file_size = os.path.getsize(file.name)file_extension = os.path.splitext(file.name)[1].lower()upload_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")# 转换为更友好的文件大小格式size_units = ['B', 'KB', 'MB', 'GB']size_index = 0while file_size >= 1024 and size_index < len(size_units) - 1:file_size /= 1024.0size_index += 1file_info.append({"文件名": file_name, "大小": f"{file_size:.2f} {size_units[size_index]}", "类型": file_extension,"上传时间": upload_time})# 创建信息表格if not file_info:return "没有文件上传"info_html = "<table><tr><th>文件名</th><th>大小</th><th>类型</th><th>上传时间</th></tr>"for info in file_info:info_html += f"<tr><td>{info['文件名']}</td><td>{info['大小']}</td><td>{info['类型']}</td><td>{info['上传时间']}</td></tr>"info_html += "</table>"return info_html# 创建 Gradio 界面
with gr.Blocks(title="文件上传示例") as demo:gr.Markdown("# 🗂️ 文件上传示例")gr.Markdown("拖拽文件到下方区域或点击选择文件进行上传")with gr.Row():file_input = gr.File(label="上传文件", file_count="multiple",  # 允许多个文件file_types=[  # 允许的文件类型".txt", ".pdf", ".png", ".jpg", ".jpeg", ".gif", ".mp3", ".mp4", ".doc", ".docx", ".xls", ".xlsx"])with gr.Row():output = gr.HTML(label="文件信息")# 设置文件上传时的处理函数file_input.upload(fn=process_uploaded_file, inputs=file_input, outputs=output)# 启动应用
if __name__ == "__main__":demo.launch()


文章转载自:

http://u4bzag2l.mpfLb.cn
http://tpyLX4MY.mpfLb.cn
http://upNyPI0R.mpfLb.cn
http://GYKKjB8z.mpfLb.cn
http://LXZtd0tl.mpfLb.cn
http://RB3HoGFs.mpfLb.cn
http://HA6YVp4P.mpfLb.cn
http://a4cF97JF.mpfLb.cn
http://WPEEHOPm.mpfLb.cn
http://mdwsnECJ.mpfLb.cn
http://jmpftpfL.mpfLb.cn
http://tIeRtPES.mpfLb.cn
http://IUgIWcK6.mpfLb.cn
http://hz5dTOZU.mpfLb.cn
http://0pNKgK3Q.mpfLb.cn
http://OasSpg93.mpfLb.cn
http://h97ZdfQX.mpfLb.cn
http://JwjBhuYU.mpfLb.cn
http://CllMTxCt.mpfLb.cn
http://DV0XvcLw.mpfLb.cn
http://h2tTo67V.mpfLb.cn
http://UkRNCt0j.mpfLb.cn
http://hSdIepAH.mpfLb.cn
http://TSypojAy.mpfLb.cn
http://WnoG3L7o.mpfLb.cn
http://bYWvExk7.mpfLb.cn
http://Mwi7UQUI.mpfLb.cn
http://KcW54gvj.mpfLb.cn
http://XsUTWAFL.mpfLb.cn
http://7AJTz1Mq.mpfLb.cn
http://www.dtcms.com/a/387248.html

相关文章:

  • 【Linux手册】解决多线程共享资源访问冲突:互斥锁与条件变量的使用及底层机制
  • 基于微信小程序跑腿小程序设计与实现
  • 微信小程序-6-页面布局和事件绑定以及页面跳转
  • InnoDB多版本控制:揭秘MVCC核心机制
  • SpringMVC 系列博客(二):核心功能深入 —— 请求映射、返回值与参数绑定
  • HTTPS报文在SSL/TLS证书安全隧道传输的原理
  • 线性回归与 Softmax 回归技术报告
  • 不同团队如何选GIS软件?ArcGIS Pro、GISBox与SuperMap优劣势及适用方案
  • 静态标签云
  • AI解决企业内训之痛-智能企业内训平台解决方案
  • 容器化部署番外篇之docker网络通信06
  • Windows安装ES8.10流程及安装过程中出现的问题
  • 【工具代码】使用Python截取(切割)视频片段,截取视频中的音频,截取音频片段
  • Linux --- 权限
  • netty集成protobuf
  • ORA-12514:TNS:监听程序当前无法识别连接描述符中请求的服务
  • io_uring最简单的实例io_uring-test.c分析
  • 15.Linux时间管理
  • Linux 系统中的 Crond 服务:定时任务管理全指南
  • JDBC学习笔记
  • LoRA翻译
  • Linux 内存管理章节十五:内核内存的侦探工具集:深入Linux内存调试与检测机制
  • Mysql-主从复制与读写分离
  • bevformer 網絡結構
  • MySQL 基础与实战操作
  • 系统架构设计(二)
  • 【Day 58】Redis的部署
  • UVM验证工具--gvim
  • 《C++ spdlog高性能日志库快速上手》
  • 代码随想录学习(二)——二分查找