I created a gui window to browse and select .jpg and .mp4 files. But i want to use the selected files as input to run another python script. How can i redirect the selected file as input in another python script. The browse GUI is below:
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
class Root(Tk):
def __init__(self):
super(Root, self).__init__()
self.title("Select a file")
self.minsize(640,400)
self.wm_iconbitmap('icon.ico')
self.labelFrame = ttk.LabelFrame(self, text = "Open a file")
self.labelFrame.grid(column = 0, row = 1, padx = 20, pady = 20)
self.button()
self.run()
def button(self):
self.button = ttk.Button(self.labelFrame, text = "Browse a file", command = self.fileDialog)
self.button.grid(column = 1, row = 1)
def run(self):
self.run = ttk.Button(self.labelFrame, text="Run", command = 'python img.py')
def fileDialog(self):
self.filename = filedialog.askopenfilename(initialdir = '/', title = "Select a file", filetypes = (("jpeg", "*.jpg"),("mp4", "*.mp4")))
self.label = ttk.Label(self.labelFrame, text = "")
self.label.grid(column = 1, row = 2)
self.label.configure(text = self.filename)
if __name__ == '__main__':
root = Root()
root.mainloop()