multithreading - Need help interacting with Python GUI while there is a process being run -


i developing application run batch of test when press start button on gui. problem once subprocess run test called, python gui freezes until subprocess finished executing. using python 2.7 way.

i interact gui while test running, have different buttons can pressed, etc. without interrupting test.

here excerpt of have part:

import tkinter import tkmessagebox import subprocess   top = tkinter.tk()  def batchstartcallback():     tkmessagebox.showinfo("batch application", "batch started!")     x in range(0, 3):         p = subprocess.call('batch path', stdout = none, stderr = none, shell=false)  def batchstopcallback():     tkmessagebox.showinfo("batch application", "batch stopped!")     # stop batch  startbutton = tkinter.button(top, text = "start batch", command = batchstartcallback, width = 8, height = 2) stopbutton = tkinter.button(top, text = "stop batch", command = batchstopcallback, width = 8, height = 2)  startbutton.pack() stopbutton.pack()  top.mainloop() 

you should use subprocess.popen non-blocking. calls subprocess.call make current script wait until subprocess has finished. in gui, endless loop run checking input , means gui unresponsive have seen. may possible initialise subprocess pool , use separate subprocess gui , run...


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -