]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/demos/Group.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / demos / Group.py
1 title = 'Pmw.Group demonstration'
2
3 # Import Pmw from this directory tree.
4 import sys
5 sys.path[:0] = ['../../..']
6
7 import Tkinter
8 import Pmw
9
10 class Demo:
11     def __init__(self, parent):
12
13         # Create and pack the Groups.
14         w = Pmw.Group(parent, tag_text='label')
15         w.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
16         cw = Tkinter.Label(w.interior(),
17                 text = 'A group with the\ndefault Label tag')
18         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
19
20         w = Pmw.Group(parent, tag_pyclass = None)
21         w.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
22         cw = Tkinter.Label(w.interior(), text = 'A group\nwithout a tag')
23         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
24
25         radiogroups = []
26         self.var = Tkinter.IntVar()
27         self.var.set(0)
28         radioframe = Tkinter.Frame(parent)
29         w = Pmw.Group(radioframe,
30                 tag_pyclass = Tkinter.Radiobutton,
31                 tag_text='radiobutton 1',
32                 tag_value = 0,
33                 tag_variable = self.var)
34         w.pack(fill = 'both', expand = 1, side='left')
35         cw = Tkinter.Frame(w.interior(),width=200,height=20)
36         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
37         radiogroups.append(w)
38
39         w = Pmw.Group(radioframe,
40                 tag_pyclass = Tkinter.Radiobutton,
41                 tag_text='radiobutton 2',
42                 tag_font = Pmw.logicalfont('Helvetica', 4),
43                 tag_value = 1,
44                 tag_variable = self.var)
45         w.pack(fill = 'both', expand = 1, side='left')
46         cw = Tkinter.Frame(w.interior(),width=200,height=20)
47         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
48         radiogroups.append(w)
49         radioframe.pack(padx = 6, pady = 6, expand='yes', fill='both')
50         Pmw.aligngrouptags(radiogroups)
51
52         w = Pmw.Group(parent,
53                 tag_pyclass = Tkinter.Checkbutton,
54                 tag_text='checkbutton',
55                 tag_foreground='blue')
56         w.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
57         cw = Tkinter.Frame(w.interior(),width=150,height=20)
58         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
59
60         w = Pmw.Group(parent,
61                 tag_pyclass = Tkinter.Button,
62                 tag_text='Tkinter.Button')
63         w.configure(tag_command = w.toggle)
64         w.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
65         cw = Tkinter.Label(w.interior(),
66                 background = 'aliceblue',
67                 text = 'A group with\na Button tag!?'
68         )
69         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
70
71         w = Pmw.Group(parent,
72                 tag_pyclass = Tkinter.Button,
73                 tag_text='Show/Hide')
74         w.configure(tag_command = w.toggle)
75         w.pack(fill = 'both', expand = 1, padx = 6, pady = 6)
76         cw = Tkinter.Label(w.interior(),
77                 background = 'aliceblue',
78                 text = 'Now you see me.\nNow you don\'t.'
79         )
80         cw.pack(padx = 2, pady = 2, expand='yes', fill='both')
81
82 ######################################################################
83
84 # Create demo in root window for testing.
85 if __name__ == '__main__':
86     root = Tkinter.Tk()
87     Pmw.initialise(root)
88     root.title(title)
89
90     exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
91     exitButton.pack(side = 'bottom')
92     widget = Demo(root)
93     root.mainloop()