/xbmc/lib/libPython/Python/Demo/tkinter/matt/window-creation-w-location.py

https://github.com/tmacreturns/XBMC_wireless_setup
Python | 45 lines | 29 code | 11 blank | 5 comment | 2 complexity | a912bad28a5050ec8cb27be3b51024a3 MD5 | raw file
  1. from Tkinter import *
  2. import sys
  3. ##sys.path.append("/users/mjc4y/projects/python/tkinter/utils")
  4. ##from TkinterUtils import *
  5. # this shows how to create a new window with a button in it that
  6. # can create new windows
  7. class QuitButton(Button):
  8. def __init__(self, master, *args, **kwargs):
  9. if not kwargs.has_key("text"):
  10. kwargs["text"] = "QUIT"
  11. if not kwargs.has_key("command"):
  12. kwargs["command"] = master.quit
  13. apply(Button.__init__, (self, master) + args, kwargs)
  14. class Test(Frame):
  15. def makeWindow(self, *args):
  16. fred = Toplevel()
  17. fred.label = Canvas (fred, width="2i", height="2i")
  18. fred.label.create_line("0", "0", "2i", "2i")
  19. fred.label.create_line("0", "2i", "2i", "0")
  20. fred.label.pack()
  21. ##centerWindow(fred, self.master)
  22. def createWidgets(self):
  23. self.QUIT = QuitButton(self)
  24. self.QUIT.pack(side=LEFT, fill=BOTH)
  25. self.makeWindow = Button(self, text='Make a New Window',
  26. width=50, height=20,
  27. command=self.makeWindow)
  28. self.makeWindow.pack(side=LEFT)
  29. def __init__(self, master=None):
  30. Frame.__init__(self, master)
  31. Pack.config(self)
  32. self.createWidgets()
  33. test = Test()
  34. test.mainloop()