Jul-18-2023, 05:53 PM
(This post was last modified: Jul-18-2023, 09:32 PM by deanhystad.)
You have a problem with the design of your program. tkinter.mainloop() blocks other code from running. You also have a loop that looks for key presses that blocks other code from running. Somehow you need to get these to work together.
I think I would move this loop:
I think I would move this loop:
Ended = 6#set arbitrary value current_state = media_player.get_state() while current_state != Ended: ...To a function that I would call periodically using root.after(milliseconds, func_to_call). Another idea is use event binding to direct key presses to some function. You are already doing this with some key presses, but not all. And there is always multi-threading. Using multi-threading you could set up a keyboard listener that runs in one thread and have tkinter run in another thread. Getting the two threads to work together can be tricky.