1 title = 'Pmw.SelectionDialog demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
11 def __init__(self, parent):
13 self.dialog = Pmw.SelectionDialog(parent,
14 title = 'My SelectionDialog',
15 buttons = ('OK', 'Cancel'),
17 scrolledlist_labelpos = 'n',
18 label_text = 'What do you think of Pmw?',
19 scrolledlist_items = ('Cool man', 'Cool', 'Good', 'Bad', 'Gross'),
20 command = self.execute)
21 self.dialog.withdraw()
23 # Create button to launch the dialog.
24 w = Tkinter.Button(parent, text = 'Show selection dialog',
25 command = self.dialog.activate)
26 w.pack(padx = 8, pady = 8)
28 def execute(self, result):
29 sels = self.dialog.getcurselection()
31 print 'You clicked on', result, '(no selection)'
33 print 'You clicked on', result, sels[0]
34 self.dialog.deactivate(result)
36 ######################################################################
38 # Create demo in root window for testing.
39 if __name__ == '__main__':
44 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
45 exitButton.pack(side = 'bottom')