Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / demos / ConfigClass.py
CommitLineData
920dae64
AT
1title = 'Component python class configuration demonstration'
2
3# Import Pmw from this directory tree.
4import sys
5sys.path[:0] = ['../../..']
6
7import Tkinter
8import Pmw
9
10class MyButton(Tkinter.Button):
11 # This is just an ordinary button with special colors.
12
13 def __init__(self, master=None, cnf={}, **kw):
14 self.__toggle = 0
15 kw['background'] = 'green'
16 kw['activebackground'] = 'red'
17 apply(Tkinter.Button.__init__, (self, master, cnf), kw)
18
19class Demo:
20 def __init__(self, parent):
21
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)
26
27 # Create and pack some EntryFields.
28 entries = []
29 entry = Pmw.EntryField(parent,
30 labelpos = 'w',
31 label_text = 'Label'
32 )
33 entry.pack(fill='x', expand=1, padx=10, pady=5)
34 entries.append(entry)
35
36 entry = Pmw.EntryField(parent,
37 labelpos = 'w',
38 label_pyclass = Tkinter.Button,
39 label_text = 'Button'
40 )
41 entry.pack(fill='x', expand=1, padx=10, pady=5)
42 entries.append(entry)
43
44 entry = Pmw.EntryField(parent,
45 labelpos = 'w',
46 label_pyclass = MyButton,
47 label_text = 'Special button'
48 )
49 entry.pack(fill='x', expand=1, padx=10, pady=5)
50 entries.append(entry)
51
52 Pmw.alignlabels(entries)
53
54 # Create and pack a ButtonBox.
55 buttonBox = Pmw.ButtonBox(parent,
56 labelpos = 'nw',
57 label_text = 'ButtonBox:')
58 buttonBox.pack(fill = 'both', expand = 1, padx=10, pady=5)
59
60 # Add some buttons to the ButtonBox.
61 buttonBox.add('with a')
62 buttonBox.add('special', pyclass = MyButton)
63 buttonBox.add('button')
64
65######################################################################
66
67# Create demo in root window for testing.
68if __name__ == '__main__':
69 root = Tkinter.Tk()
70 Pmw.initialise(root)
71 root.title(title)
72
73 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
74 exitButton.pack(side = 'bottom')
75 widget = Demo(root)
76 root.mainloop()