简体   繁体   中英

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

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()

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"])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM