/Demo/tkinter/matt/packer-simple.py

http://unladen-swallow.googlecode.com/ · Python · 32 lines · 21 code · 9 blank · 2 comment · 0 complexity · 5d51b488796fee79f18dade9f7797a75 MD5 · raw file

  1. from Tkinter import *
  2. class Test(Frame):
  3. def printit(self):
  4. print self.hi_there["command"]
  5. def createWidgets(self):
  6. # a hello button
  7. self.QUIT = Button(self, text='QUIT', foreground='red',
  8. command=self.quit)
  9. self.QUIT.pack(side=LEFT, fill=BOTH)
  10. self.hi_there = Button(self, text='Hello',
  11. command=self.printit)
  12. self.hi_there.pack(side=LEFT)
  13. # note how Packer defaults to side=TOP
  14. self.guy2 = Button(self, text='button 2')
  15. self.guy2.pack()
  16. self.guy3 = Button(self, text='button 3')
  17. self.guy3.pack()
  18. def __init__(self, master=None):
  19. Frame.__init__(self, master)
  20. Pack.config(self)
  21. self.createWidgets()
  22. test = Test()
  23. test.mainloop()