The code below works to play a video file (did not include the video file here), but problem is: If I pause the video by right clicking, then 'x' out the window (or right click title bar and select 'close') the window freezes and will not close until I shut down the python program. I have tried dozens including threading etc, but always get stuck at the same freeze point.
#!/usr/bin/python3 import os import shutil import tkinter as tk from tkinter import * from tkinter import filedialog import mpv player = mpv.MPV(input_default_bindings=True,input_vo_keyboard=True,osc=True) window=tk.Tk() currdir=os.getcwd() path=filedialog.askopenfilename(parent=window,initialdir=currdir, title="Select file") # above code works to select file, I entered a filename below to test if a direct filename causes same problem, and it does try: player.play('/home/rainer/Videos/Garage62-2021-02-06__09-16-51.mkv') finally: window.destroy() window.mainloop()