Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Basic GUI for shell commands with Python Tk threading and os

By: a guest on Jul 4th, 2011  |  syntax: Python  |  size: 0.73 KB  |  hits: 87  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import sys
  2. from Tkinter import *
  3. from os import system as run
  4. from time import sleep
  5. import thread
  6.  
  7. r = Tk()
  8. r.title('Remote Support')
  9. t = StringVar()
  10. t.set('Completing Remote Support Initalisation         ')
  11. l = Label(r,  textvariable=t).pack()
  12. def quit():
  13.         #do cleanup if any
  14.         r.destroy()
  15. but = Button(r, text='Stop Remote Support', command=quit)
  16. but.pack(side=LEFT)
  17.  
  18. def d():
  19.         sleep(2)
  20.         t.set('Completing Remote Support Initalisation, downloading, please wait         ')
  21.         run('sleep 5') #test shell command
  22.         t.set('Preparing to run download, please wait         ')
  23.         run('sleep 5')
  24.         t.set("OK thanks! Remote Support will now close         ")
  25.         sleep(2)
  26.         quit()
  27.  
  28. sleep(2)
  29. thread.start_new_thread(d,())
  30. r.mainloop()