]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/demos/MultiLineLabel.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / demos / MultiLineLabel.py
1 title = 'Multi-line label demonstration'
2
3 # Import Pmw from this directory tree.
4 import sys
5 sys.path[:0] = ['../../..']
6
7 import string
8 import Tkinter
9 import Pmw
10
11 class 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.
65 if __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()