-
添加进度组件
pythondef download(): # 创建下载进度框 progress_window = tk.Toplevel() progress_window.title("下载进度") progress_label = tk.Label(progress_window, text="正在下载视频文件...") progress_label.pack(pady=10) progress_bar = ttk.Progressbar(progress_window, orient="horizontal", length=300, mode="determinate") progress_bar.pack(pady=10) # 获取窗口宽高并居中显示 progress_window.update_idletasks() window_width = progress_window.winfo_width() window_height = progress_window.winfo_height() screen_width = progress_window.winfo_screenwidth() screen_height = progress_window.winfo_screenheight() x = (screen_width - window_width) // 2 y = (screen_height - window_height) // 2 progress_window.geometry(f"{window_width}x{window_height}+{x}+{y}") -
创建进度更新方法
pythondef update_progress(progress): progress_bar['value'] = progress progress_window.update_idletasks() -
调用下载方法,传入进度更新方法
pythonls_setoption.get_dump_video(video_dir, progress_callback=update_progress) progress_window.destroy() -
使用子线程调用下载方法,注意用子线程,否则下载过程UI会卡死,进度不更新
pythondownload_thread = threading.Thread(target=download) download_thread.start()
python使用tkinter添加下载进度UI
ChatGPT攻城狮2024-07-10 7:03
相关推荐
默_笙4 天前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的qq_426003964 天前
启动playwright录制codegen生成自动化测试脚本虎头金猫4 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺长沙三为智能科技4 天前
家政小程序开发从0到上线:五阶段交付流程与验收清单大蓝头4 天前
安装包UI美化之路-nsNiuniuSkin全新UI调试与预览方法伞伞悦读4 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__只睡四小时4 天前
Canvas 弹道联机实战:700 行 + 固定时间步长奇思妙想聪明勤奋的小羊5 天前
DeepAgents第5章:子Agent 与上下文隔离—让 Agent学会委派lpfasd1235 天前
2026年第38周GitHub趋势周报IZero075 天前
Jev 与 Laya