title: Color a Button after subprocess has finished
body: <p>I have a Tk python program that creates a list of python files in the current directory and generates a button for each of them. When you click a button the corresponding python program is launched via subprocess in a new gnome-terminal. I'd like to switch the button's color to red after the subprocess has finished executing on the new terminal. Unfortunately, the button is changing color almost immediately.</p>
  
  <pre><code>from Tkinter import *
  import os, subprocess
  
  root = Tk()
  buttonsD = {}
  
  def launch(ourfile):
      p=subprocess.Popen(["gnome-terminal","-e","python " + ourfile], shell=False)
      buttonsD[ourfile].configure(bg='red')
  
  dirlist=os.listdir(os.getcwd())
  for fname in dirlist:
      if fname.endswith('py') and fname != 'gui2.py':
          buttonsD[fname] = Button(root,text=fname,command=lambda i=fname: launch(i))
          buttonsD[fname].pack(side=TOP,expand=YES,fill=BOTH)
  
  root.mainloop()
  </code></pre>
  
  <p>Almost immediately means that I can wait while p.poll == None, and see that it takes a moment for gnome-terminal to be created. But as soon as the terminal is created the button goes red, even though a process is still running in the new terminal. I can't create a new gnome-terminal and then communicate the process I'd like to run either. It seems gnome-terminal just creates a new instance of bash and then returns done, so there's a pipe error if I try to communicate to its stdin.</p>