Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | title = 'Pmw.ComboBoxDialog demonstration' |
2 | ||
3 | # Import Pmw from this directory tree. | |
4 | import sys | |
5 | sys.path[:0] = ['../../..'] | |
6 | ||
7 | import Tkinter | |
8 | import Pmw | |
9 | ||
10 | class Demo: | |
11 | def __init__(self, parent): | |
12 | # Create the dialog. | |
13 | self.dialog = Pmw.ComboBoxDialog(parent, | |
14 | title = 'My ComboBoxDialog', | |
15 | buttons = ('OK', 'Cancel'), | |
16 | defaultbutton = 'OK', | |
17 | combobox_labelpos = 'n', | |
18 | label_text = 'What do you think of Pmw?', | |
19 | scrolledlist_items = ('Cool man', 'Cool', 'Good', 'Bad', 'Gross')) | |
20 | self.dialog.withdraw() | |
21 | ||
22 | # Create button to launch the dialog. | |
23 | w = Tkinter.Button(parent, | |
24 | text = 'Show combo box dialog', | |
25 | command = self.doit) | |
26 | w.pack(padx = 8, pady = 8) | |
27 | ||
28 | def doit(self): | |
29 | result = self.dialog.activate() | |
30 | print 'You clicked on', result, self.dialog.get() | |
31 | ||
32 | ###################################################################### | |
33 | ||
34 | # Create demo in root window for testing. | |
35 | if __name__ == '__main__': | |
36 | root = Tkinter.Tk() | |
37 | Pmw.initialise(root) | |
38 | root.title(title) | |
39 | ||
40 | exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy) | |
41 | exitButton.pack(side = 'bottom') | |
42 | widget = Demo(root) | |
43 | root.mainloop() | |
44 |