Advertisement
Guest User

Untitled

a guest
Jan 15th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #! /usr/bin/env python
  2. import Tkinter as tk
  3. import subprocess, threading
  4. tabella = (
  5. ('nome_comando1','comando1'),
  6. ('nome_comando2','comando2'),
  7. ('nome_comando3','comando3'),
  8. )
  9. def avvia(evento):
  10. nuovo_thread = threading.Thread(
  11. target=lambda:subprocess.call(evento.widget.comando))
  12. nuovo_thread.start()
  13. evento.widget.update()
  14. finestra = tk.Tk()
  15. finestra.title('titolo_finestra')
  16. finestra.resizable(False, False)
  17. lb = []
  18. for indice, (testo, comando) in enumerate(tabella):
  19. lb.append(tk.Button(finestra, text=testo, width=30))
  20. lb[indice].comando = comando
  21. lb[indice].bind('<Button-1>', avvia)
  22. lb[indice].pack()
  23. finestra.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement