Feb-17-2021, 12:07 AM
TY - that works! But only when I use it as a standalone.
When I plug it into the function of the (initially posted) script, one of two things happen:
1- if I halt the strem (rightclick) and try to close the window the stream is playing in, the window freezes and I have to close the program from IDLE (or a quit button I have in it).
2- If I let the video/s run through to end, the window closes. But, if I try to select more files via Browse button (activating askopenfilenames()) then the program closes down abruptly as soon as the new file selections are made.
Essentially, this happens with your code and with mine.
I haven't a clue what to try next!
I made a shorter version of the program (removed the other labes/buttons/functions) to it's easier on the eye to look through:
When I plug it into the function of the (initially posted) script, one of two things happen:
1- if I halt the strem (rightclick) and try to close the window the stream is playing in, the window freezes and I have to close the program from IDLE (or a quit button I have in it).
2- If I let the video/s run through to end, the window closes. But, if I try to select more files via Browse button (activating askopenfilenames()) then the program closes down abruptly as soon as the new file selections are made.
Essentially, this happens with your code and with mine.
I haven't a clue what to try next!
I made a shorter version of the program (removed the other labes/buttons/functions) to it's easier on the eye to look through:
#!/usr/bin/python3 import os import shutil import tkinter as tk from tkinter import * from tkinter import filedialog, messagebox from tkinter import ttk import mpv player = mpv.MPV(ytdl=True,input_default_bindings=True,input_vo_keyboard=True,osc=True) media = open('mPlaylist.u3e', 'r').read().splitlines() # Creating object of tk class root = tk.Tk() root.title("Motion GUI") root.minsize(width=1000, height=700) root.maxsize(width=1400, height = 900) mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N,W,E,S)) root.columnconfigure(0, weight=1) root.rowconfigure(0,weight=1) WidgetFrame = ttk.Frame(mainframe, borderwidth=2,relief='ridge',height = 60) WidgetFrame.grid(column=0,row=0, sticky="E,W") root.geometry("830x420") root.title("View/Copy/Move/Delete mkv's") root.config(background = "gray") def CreateWidgets(): WidgetFrame.link_Label = Label(WidgetFrame, text ="Select File(s): ", bg = "#E8D579") WidgetFrame.link_Label.grid(row = 1, column = 0, pady = 5, padx = 5) WidgetFrame.sourceText = Entry(WidgetFrame, width = 50, textvariable = sourceLocation) WidgetFrame.sourceText.grid(row = 1, column = 1, pady = 5, padx = 5, columnspan = 2) WidgetFrame.source_browseButton = Button(WidgetFrame, text ="Browse", command = SourceBrowse, width = 15) WidgetFrame.source_browseButton.grid(row = 1, column = 3, pady = 5, padx = 5) WidgetFrame.viewButton = Button(WidgetFrame, text ="View File(s)", command = ViewFile, width = 15) WidgetFrame.viewButton.grid(row = 3, column = 0, pady = 5, padx = 5) def SourceBrowse(): # Opening the file-dialog directory prompting the user to select files to copy using # filedialog.askopenfilenames() method. Setting initialdir argument is optional Since multiple # files may be selected, converting the selection to list using list() WidgetFrame.files_list = list(filedialog.askopenfilenames(initialdir ="/home/rainer/Videos",title="Press shift key plus Left mouse click to select multiple files")) files_list = [] # Displaying the selected files in the WidgetFrame.sourceText Entry using WidgetFrame.sourceText.insert() WidgetFrame.sourceText.insert('1', WidgetFrame.files_list) def ViewFile(): try: for item in media: player.play(item) player.wait_for_playback() except mpv.ShutdownError: pass # Creating tkinter variable sourceLocation = StringVar() destinationLocation = StringVar() files_list = StringVar() # Calling the CreateWidgets() function CreateWidgets() # Defining infinite loop root.mainloop()