1 title = 'Pmw.ButtonBox demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
11 def __init__(self, parent):
12 # Create and pack the ButtonBox.
13 self.buttonBox = Pmw.ButtonBox(parent,
15 label_text = 'ButtonBox:',
16 frame_borderwidth = 2,
17 frame_relief = 'groove')
18 self.buttonBox.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
20 # Add some buttons to the ButtonBox.
21 self.buttonBox.add('OK', command = self.ok)
22 self.buttonBox.add('Apply', command = self.apply)
23 self.buttonBox.add('Cancel', command = self.cancel)
25 # Set the default button (the one executed when <Return> is hit).
26 self.buttonBox.setdefault('OK')
27 parent.bind('<Return>', self._processReturnKey)
30 # Make all the buttons the same width.
31 self.buttonBox.alignbuttons()
33 def _processReturnKey(self, event):
34 self.buttonBox.invoke()
37 print 'You clicked on OK'
40 print 'You clicked on Apply'
43 print 'You clicked on Cancel'
45 ######################################################################
47 # Create demo in root window for testing.
48 if __name__ == '__main__':
53 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
54 exitButton.pack(side = 'bottom')