1 title = 'Multi-line label demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
12 def __init__(self, parent):
14 frame = Tkinter.Frame(parent, background = '#eeeeee')
15 frame.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
17 stickys = ('n', 's', 'e', 'w', 'ns', 'ew', 'ne', 'nw', 'se', 'sw',
18 'nsw', 'nse', 'new', 'sew', 'nsew',)
24 # Choose one megawidget class to demonstrate:
28 # cls = Pmw.LabeledWidget
29 # cls = Pmw.MessageBar
31 for sticky in stickys:
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)
52 widgets.append(widget)
60 Pmw.alignlabels(widgets, sticky = 'e')
62 ######################################################################
64 # Create demo in root window for testing.
65 if __name__ == '__main__':
70 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
71 exitButton.pack(side = 'bottom')