blob: 3a0e19643482d59bcbf1db28e102f230252647aa [file] [log] [blame]
Guido van Rossum35820f71994-10-07 09:55:26 +00001from Tkinter import *
2
3# This is a program that makes a simple two button application
4
5
6class New_Button(Button):
7 def callback(self):
8 print self.counter
9 self.counter = self.counter + 1
10
11def createWidgets(top):
12 f = Frame(top)
13 f.pack()
14 f.QUIT = Button(f, {'text': 'QUIT',
15 'fg': 'red',
16 'command': top.quit})
17
18 f.QUIT.pack({'side': 'left', 'fill': 'both'})
19
20
21 # a hello button
22 f.hi_there = New_Button(f, {'text': 'Hello'})
23 # we do this on a different line because we need to reference f.hi_there
24 f.hi_there.config({'command' : f.hi_there.callback})
25 f.hi_there.pack({'side': 'left'})
26 f.hi_there.counter = 43
27
28
29
30root = Tk()
31createWidgets(root)
32root.mainloop()
33