I have just started learning PySimpleGUI and I wanted to create a custom GUI progress bar that will display what parts of the program are running at different times.
For example, I have a video processing program with various components so I want the progress bar to display text like:
'Extracting Frame 1 from Video'
'Cropping images'
'Removing Duplicate Images'
But all these lines require updating the progress bar window from different functions in the program where the GUI code associated with the window containing the progress bar is not running.
My code:
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)
Here, I need to update the GUI Process bar from within the 'Frame_Capture', 'Remove_Duplicates', 'makePDF' and 'Cleanup' functions when the GUI component of my program itself is running in another part of the program.
The two solutions I can think of are:
- Creating my window globally and updating the progress bar in it globally
- Writing all my progress bar statements into a text file line by line when my program reaches a part where the progress bar needs to be updated and simultaneously loading the latest statement from the text file into my progress bar every few milliseconds.
Neither of these solutions sound good. Is there some other way I can do this?