我刚刚开始学习 PySimpleGUI,我想创建一个自定义 GUI 进度条,它将显示程序的哪些部分在不同时间正在运行。
例如,我有一个包含各种组件的视频处理程序,因此我希望进度栏显示如下文本:
“从视频中提取第一帧”
“裁剪图像”
“删除重复图像”
但所有这些行都需要从程序中的不同函数更新进度条窗口,其中与包含进度条的窗口关联的 GUI 代码未运行。
我的代码:
image_name_list = Frame_Capture(f"{main_dir}\\{input_line2}.mp4") # Generates image list of frames of video
Remove_Duplicates(image_name_list) # Removes duplicate images
print("Enter name of pdf file")
pdf_name = f'{input()}.pdf'
makePdf(pdf_name, image_name_list) # Converts images to pdf
Cleanup(image_name_list) # Deletes unneeded images
os.startfile(pdf_name)
Run Code Online (Sandbox Code Playgroud)
在这里,当我的程序本身的 GUI 组件在程序的另一部分中运行时,我需要从“Frame_Capture”、“Remove_Duplicates”、“makePDF”和“Cleanup”功能中更新 GUI 进程栏。
我能想到的两种解决方案是:
这些解决方案听起来都不好。我还有其他方法可以做到这一点吗?