I have a gui in which it should open a program and the quit the program when the quit button is pressed. The code is as follows:
#!/usr/bin/python
import Tkinter as tk
import subprocess
import os
import signal
class StageGui:
def __init__(self,parent):
self.process = None
self.f = tk.Frame(main, width=300, height=300)
self.b1=tk.Button(main,text='Start Medina',command=self.startmedina).pack(side='left',anchor='nw')
self.b2=tk.Button(main,text='Quit Medina',command=self.quitmedina).pack(side='left',anchor='nw')
self.xf = tk.Frame(self.f,relief='groove', borderwidth=2)
def startmedina(self):
self.process=subprocess.Popen(['pre xx'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True,preexec_fn=os.setsid)
return
def quitmedina(self):
os.killpg(self.process.pid,signal.SIGKILL)
return
main = tk.Tk()
stagegui=StageGui(main)
main.title('prototype')
main.mainloop()
When i press the start button the program opens but when press the quit it does'nt kill the subprocess. can any one help me with this?