blob: 64f61d5fff471f32a2147220f6cd69621e1d478f [file] [log] [blame]
Benjamin Petersond6d63f52009-01-04 18:53:28 +00001from tkinter import *
Guido van Rossum35820f71994-10-07 09:55:26 +00002
3
4class Test(Frame):
5 def printit(self):
Collin Winter6f2df4d2007-07-17 20:59:35 +00006 print(self.hi_there["command"])
Guido van Rossum35820f71994-10-07 09:55:26 +00007
8 def createWidgets(self):
Tim Peters182b5ac2004-07-18 06:16:08 +00009 # a hello button
10 self.QUIT = Button(self, text='QUIT', foreground='red',
11 command=self.quit)
12 self.QUIT.pack(side=LEFT, fill=BOTH)
Guido van Rossum35820f71994-10-07 09:55:26 +000013
Tim Peters182b5ac2004-07-18 06:16:08 +000014 self.hi_there = Button(self, text='Hello',
15 command=self.printit)
16 self.hi_there.pack(side=LEFT)
Guido van Rossum35820f71994-10-07 09:55:26 +000017
Tim Peters182b5ac2004-07-18 06:16:08 +000018 # note how Packer defaults to side=TOP
Guido van Rossum35820f71994-10-07 09:55:26 +000019
Tim Peters182b5ac2004-07-18 06:16:08 +000020 self.guy2 = Button(self, text='button 2')
21 self.guy2.pack()
Guido van Rossum35820f71994-10-07 09:55:26 +000022
Tim Peters182b5ac2004-07-18 06:16:08 +000023 self.guy3 = Button(self, text='button 3')
24 self.guy3.pack()
Guido van Rossum35820f71994-10-07 09:55:26 +000025
26 def __init__(self, master=None):
Tim Peters182b5ac2004-07-18 06:16:08 +000027 Frame.__init__(self, master)
28 Pack.config(self)
29 self.createWidgets()
Guido van Rossum35820f71994-10-07 09:55:26 +000030
31test = Test()
32test.mainloop()