1 title = 'Component python class configuration demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
10 class MyButton(Tkinter.Button):
11 # This is just an ordinary button with special colors.
13 def __init__(self, master=None, cnf={}, **kw):
15 kw['background'] = 'green'
16 kw['activebackground'] = 'red'
17 apply(Tkinter.Button.__init__, (self, master, cnf), kw)
20 def __init__(self, parent):
22 # Create a title label:
23 label = Tkinter.Label(parent,
24 text = 'EntryFields with label components of specified type:')
25 label.pack(fill='x', expand=1, padx=10, pady=5)
27 # Create and pack some EntryFields.
29 entry = Pmw.EntryField(parent,
33 entry.pack(fill='x', expand=1, padx=10, pady=5)
36 entry = Pmw.EntryField(parent,
38 label_pyclass = Tkinter.Button,
41 entry.pack(fill='x', expand=1, padx=10, pady=5)
44 entry = Pmw.EntryField(parent,
46 label_pyclass = MyButton,
47 label_text = 'Special button'
49 entry.pack(fill='x', expand=1, padx=10, pady=5)
52 Pmw.alignlabels(entries)
54 # Create and pack a ButtonBox.
55 buttonBox = Pmw.ButtonBox(parent,
57 label_text = 'ButtonBox:')
58 buttonBox.pack(fill = 'both', expand = 1, padx=10, pady=5)
60 # Add some buttons to the ButtonBox.
61 buttonBox.add('with a')
62 buttonBox.add('special', pyclass = MyButton)
63 buttonBox.add('button')
65 ######################################################################
67 # Create demo in root window for testing.
68 if __name__ == '__main__':
73 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
74 exitButton.pack(side = 'bottom')