As a bit of a background, I picked up a project from another developer who wrote the entire as one big file that runs from top to bottom.
The manager wants to display images / videos on the screen at certain points during the scripts execution and that disappear during other points of execution.
I have worked with Tk extensively, but I am still limited by the lack of thread safeness and its blocking mainloop()
function.
Is there a way in python to display images / videos asynchronously/ in a non blocking way, while the main thread still executes? In the context of this project, the API would have to be something similar to what is below.
if __name__ == "__main__":
gui = load_gui()
gui.display_image("doing_math.png") #doesn't block
for i in range(0, 500):
print(str(i))
gui.display_image("math_complete.mp4")#doesn't block
sleep(2)
gui.clear_display()
currently I am using trying to use Tk like displayed below. but it is limited by the mainloop() blocking the rest of the scripts execution.
class MediaGui(tk.Tk):
def __init__(self):
self.mainloop()
...
gui = MediaGui() #this line blocks because of mainloop
gui.load_image("image.png")