Advertisement
Guest User

Untitled

a guest
Nov 15th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. _dynamic_childs = {}
  2. def _dynamic_tab(name, text):
  3. tab = widgets.right.insert("end", name, text=text)
  4. tab.configure(borderwidth=1, highlightthickness=0)
  5. return tab
  6.  
  7. def _dynamic_tabs(inifile):
  8. from subprocess import Popen
  9. tab_names = inifile.findall("DISPLAY", "EMBED_TAB_NAME")
  10. tab_cmd = inifile.findall("DISPLAY", "EMBED_TAB_COMMAND")
  11. if len(tab_names) != len(tab_cmd):
  12. print "Invalid tab configuration"
  13. # Complain somehow
  14. return
  15. for i,t,c in zip(range(len(tab_cmd)), tab_names, tab_cmd):
  16. w = _dynamic_tab("user_" + str(i), t)
  17. f = Tkinter.Frame(w, container=1, borderwidth=0, highlightthickness=0)
  18. f.pack(fill="both", expand=1)
  19. xid = f.winfo_id()
  20. cmd = c.replace('{XID}', str(xid))
  21. child = Popen(cmd.split())
  22. _dynamic_childs[str(w)] = child
  23.  
  24. @atexit.register
  25. def kill_dynamic_childs():
  26. for c in _dynamic_childs.values():
  27. c.terminate()
  28.  
  29. _dynamic_tabs(inifile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement