doc++
[minwii.git] / src / pgu / gui / group.py
1 """
2 """
3 from const import *
4 import widget
5
6 class Group(widget.Widget):
7 """An object for grouping together Form elements.
8
9 <pre>Group(name=None,value=None)</pre>
10
11 <dl>
12 <dt>name<dd>name as used in the Form
13 <dt>value<dd>values that are currently selected in the group
14 </dl>
15
16 <p>See [[gui-button]] for several examples.</p>
17
18 <p>When the value changes, an <tt>gui.CHANGE</tt> event is sent.
19 Although note, that when the value is a list, it may have to be sent by hand via
20 <tt>g.send(gui.CHANGE)</tt></p>
21 """
22
23 def __init__(self,name=None,value=None):
24 widget.Widget.__init__(self,name=name,value=value)
25 self.widgets = []
26
27 def add(self,w):
28 """Add a widget to this group.
29
30 <pre>Group.add(w)</pre>
31 """
32 self.widgets.append(w)
33
34 def __setattr__(self,k,v):
35 _v = self.__dict__.get(k,NOATTR)
36 self.__dict__[k] = v
37 if k == 'value' and _v != NOATTR and _v != v:
38 self._change()
39
40 def _change(self):
41 self.send(CHANGE)
42 for w in self.widgets:
43 w.repaint()