diff options
author | Sin Nombre <sin@ubuntu.(none)> | 2010-05-28 20:45:29 (GMT) |
---|---|---|
committer | Sin Nombre <sin@ubuntu.(none)> | 2010-05-28 20:45:29 (GMT) |
commit | 9e93d1b9802385900b6f833f81f84c0ac50f91ef (patch) | |
tree | f2c16599bde31b31e5d44bae4a87e7e4093f3cab /pgu/gui/group.py | |
parent | ac8cbb6691ba3de1c7c42f4362edbe11270f4506 (diff) |
Diffstat (limited to 'pgu/gui/group.py')
-rw-r--r-- | pgu/gui/group.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pgu/gui/group.py b/pgu/gui/group.py new file mode 100644 index 0000000..bcb231a --- /dev/null +++ b/pgu/gui/group.py @@ -0,0 +1,43 @@ +""" +""" +from const import * +import widget + +class Group(widget.Widget): + """An object for grouping together Form elements. + + <pre>Group(name=None,value=None)</pre> + + <dl> + <dt>name<dd>name as used in the Form + <dt>value<dd>values that are currently selected in the group + </dl> + + <p>See [[gui-button]] for several examples.</p> + + <p>When the value changes, an <tt>gui.CHANGE</tt> event is sent. + Although note, that when the value is a list, it may have to be sent by hand via + <tt>g.send(gui.CHANGE)</tt></p> + """ + + def __init__(self,name=None,value=None): + widget.Widget.__init__(self,name=name,value=value) + self.widgets = [] + + def add(self,w): + """Add a widget to this group. + + <pre>Group.add(w)</pre> + """ + self.widgets.append(w) + + def __setattr__(self,k,v): + _v = self.__dict__.get(k,NOATTR) + self.__dict__[k] = v + if k == 'value' and _v != NOATTR and _v != v: + self._change() + + def _change(self): + self.send(CHANGE) + for w in self.widgets: + w.repaint() |