File: group.py

package info (click to toggle)
python-box2d 2.3.2~dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,596 kB
  • ctags: 5,116
  • sloc: python: 14,384; cpp: 13,393; makefile: 9
file content (49 lines) | stat: -rw-r--r-- 1,127 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"""
"""
from .const import *
from . import widget

class Group(widget.Widget):
    """An object for grouping together Form elements.
    
    When the value changes, an gui.CHANGE event is sent. Although note, 
    that when the value is a list, it may have to be sent by hand via 
    g.send(gui.CHANGE).

    """

    _value = None
    widgets = None
    
    def __init__(self,name=None,value=None):
        """Create Group instance.

        Arguments:
        name -- name as used in the Form
        value -- values that are currently selected in the group
    
        """
        widget.Widget.__init__(self,name=name,value=value)
        self.widgets = []
    
    def add(self,w):
        """Add a widget to this group."""
        self.widgets.append(w)

    @property
    def value(self):
        return self._value

    @value.setter
    def value(self, val):
        oldval = self._value
        self._value = val
        if (oldval != val):
            self._change()
    
    def _change(self):
        self.send(CHANGE)
        if (self.widgets):
            for w in self.widgets:
                w.repaint()