#changed all email address to go through python.org
[python/dscho.git] / Demo / tkinter / matt / subclass-existing-widgets.py
blob3a0e19643482d59bcbf1db28e102f230252647aa
1 from Tkinter import *
3 # This is a program that makes a simple two button application
6 class New_Button(Button):
7 def callback(self):
8 print self.counter
9 self.counter = self.counter + 1
11 def createWidgets(top):
12 f = Frame(top)
13 f.pack()
14 f.QUIT = Button(f, {'text': 'QUIT',
15 'fg': 'red',
16 'command': top.quit})
18 f.QUIT.pack({'side': 'left', 'fill': 'both'})
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
30 root = Tk()
31 createWidgets(root)
32 root.mainloop()