Package pyforms :: Package terminal :: Package Controls :: Module ControlCombo |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.terminal.Controls.ControlCombo

     1  from pyforms.terminal.Controls.ControlBase import ControlBase
     2
     3 -class ControlCombo(ControlBase):
     4
     5      _items = None
     6
     7 -    def initControl(self):
     8          self._items = {}
     9          self._addingItem = False
    10          return "controls.push(new ControlCombo('%s','%s', []));" % (self._label, self._name)
    11
    12 -    def currentIndexChanged(self, index):
    13          #if not self._addingItem:
    14              #item = self._form.comboBox.currentText()
    15          #    if len(item)>=1: OTControlBase.value.fset(self, self._items[str(item)])
    16          return 0
    17
    18 -    def addItem(self, label, value = None):
    19          if self._items==None: self._items={}
    20          self._addingItem = True
    21          #if not (label in self._items.keys()):
    22          #    self._form.comboBox.addItem( label )
    23
    24          firstValue = False
    25          if self._items=={}: firstValue = True
    26
    27          if value==None:
    28              self._items[label] = label
    29          else:
    30              self._items[label] = value
    31          self._addingItem = False
    32
    33          if firstValue: self.value = self._items[label]
    34
    35
    36 -    def clearItems(self):
    37          self._items = {}
    38          self._value = None
    39          #self._form.comboBox.clear()
    40
    41      @property
    42 -    def items(self): return self._items.values()
    43
    44      @property
    45 -    def values(self): return self._items.items()
    46
    47      @property
    48 -    def value(self): return self._value
    49
    50      @value.setter
    51 -    def value(self, value):
    52          for key, val in self._items.items():
    53              if value == val:
    54                  if self._value!=value: self.valueUpdated(value)
    55                  self._value = val
    56
    57      @property
    58 -    def text(self): return "";#str(self._form.comboBox.currentText())
    59
    60      @text.setter
    61 -    def text(self, value):
    62          for key, val in self._items.items():
    63              if value == key:
    64                  self.value = val
    65                  break
    66