Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / lib / python2.4 / site-packages / Pmw / Pmw_1_2 / demos / MultiLineLabel.py
CommitLineData
920dae64
AT
1title = 'Multi-line label demonstration'
2
3# Import Pmw from this directory tree.
4import sys
5sys.path[:0] = ['../../..']
6
7import string
8import Tkinter
9import Pmw
10
11class Demo:
12 def __init__(self, parent):
13
14 frame = Tkinter.Frame(parent, background = '#eeeeee')
15 frame.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
16
17 stickys = ('n', 's', 'e', 'w', 'ns', 'ew', 'ne', 'nw', 'se', 'sw',
18 'nsw', 'nse', 'new', 'sew', 'nsew',)
19
20 widgets = []
21 row = 0
22 column = 0
23
24 # Choose one megawidget class to demonstrate:
25 cls = Pmw.EntryField
26 # cls = Pmw.Counter
27 # cls = Pmw.ComboBox
28 # cls = Pmw.LabeledWidget
29 # cls = Pmw.MessageBar
30
31 for sticky in stickys:
32 dict = {}
33 dict['sticky'] = sticky
34 dict['labelpos'] = 'w'
35 dict['label_text'] = '1\n' + sticky + ':\n3'
36 if cls == Pmw.EntryField:
37 dict['value'] = sticky
38 dict['entry_width'] = 6
39 if cls == Pmw.Counter or cls == Pmw.ComboBox:
40 dict['entryfield_value'] = sticky
41 dict['entry_width'] = 6
42 widget = apply(cls, (frame,), dict)
43 if cls == Pmw.LabeledWidget:
44 f = Tkinter.Button(widget.interior(), text = sticky)
45 f.pack(fill = 'both', expand = 1)
46 if cls == Pmw.MessageBar:
47 widget.message('state', sticky)
48 widget.grid(column=column, row=row, sticky='ew', padx = 10, pady = 5)
49 frame.grid_columnconfigure(column, weight=1)
50 frame.grid_rowconfigure(row, weight=1)
51
52 widgets.append(widget)
53
54 if row < 4:
55 row = row + 1
56 else:
57 row = 0
58 column = column + 1
59
60 Pmw.alignlabels(widgets, sticky = 'e')
61
62######################################################################
63
64# Create demo in root window for testing.
65if __name__ == '__main__':
66 root = Tkinter.Tk()
67 Pmw.initialise(root)
68 root.title(title)
69
70 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
71 exitButton.pack(side = 'bottom')
72 widget = Demo(root)
73 root.mainloop()