Home > database >  Normally i run on command line : python main.py image/ archive/ True , so how can i run on tkinter g
Normally i run on command line : python main.py image/ archive/ True , so how can i run on tkinter g

Time:05-13

This is my code, Thanks everybody.

import subprocess
import sys
import tkinter as tk
import tkinter.filedialog

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()
        self.image = "image/"
        self.archive = "archive/"

    def create_widgets(self):

        tk.Button(self, text="Run", command=self.run_face_recognition).pack(fill=tk.X)
        tk.Button(self, text="Quit", command=self.master.destroy).pack(fill=tk.X)


    def run_face_recognition(self):
        subprocess.run([sys.executable, "main.py","--image/", "--archive/",  self.image,  self.archive, "args..."])

root = tk.Tk()
app = Application(master=root)
app.mainloop()

CodePudding user response:

If you don't use --image and --archive when running the command by hand, you don't need them here.

Just add True as another argument in the list.

    def run_face_recognition(self):
        subprocess.run([sys.executable, "main.py",  self.image,  self.archive, "True"])
  • Related