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

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

      1  import os, pickle,uuid
      2
      3
      4 -class ControlBase(object):
      5
      6      _value          = None
      7      _label          = None
      8      _controlHTML    = ""
      9
     10 -    def __init__(self, label = "", defaultValue = "", helptext=None):
     11          self._name = ""
     12          self._id = uuid.uuid4()
     13          self._value = defaultValue
     14          self._parent = 1
     15          self._label = label
     16          self._popupMenu = None
     17          self._controlHTML  = ""
     18
     19
     20 -    def initControl(self):
     21          self._controlHTML = "<div id='id%s' ><input type='text' id='%s' /></div>" % ( self._id, self._name )
     22          return self._controlHTML
     23
     24 -    def finishEditing(self): self.updateControl()
     25
     26 -    def updateControl(self): pass
     27
     28 -    def load(self, data):
     29          if 'value' in data: self.value = data['value']
     30
     31 -    def save(self, data):
     32          if self.value: data['value'] = self.value
     33
     34 -    def valueUpdated(self, value): pass
     35
     36 -    def show(self):pass
     37
     38 -    def hide(self):pass
     39
     40 -    def openPopupMenu(self, position): pass
     41
     42
     43 -    def addPopupSubMenuOption(self, label, options): pass
     44
     45
     46 -    def addPopupMenuOption(self, label, functionAction = None): pass
     47
     48 -    def __repr__(self):
     49          return self.value
     50      ############################################################################
     51      ############ Properties ####################################################
     52      ############################################################################
     53
     54      @property
     55 -    def enabled(self): return True
     56
     57      @enabled.setter
     58 -    def enabled(self, value): pass
     59
     60      ############################################################################
     61
     62      @property
     63 -    def value(self): return self._value
     64
     65      @value.setter
     66 -    def value(self, value):
     67          oldvalue = self._value
     68          self._value = value
     69          if oldvalue!=value: self.valueUpdated(value)
     70
     71      ############################################################################
     72
     73      @property
     74 -    def label(self): return self._label
     75
     76      @label.setter
     77 -    def label(self, value): self._label = value
     78
     79      ############################################################################
     80
     81      @property
     82 -    def form(self): return None
     83
     84      ############################################################################
     85
     86      @property
     87 -    def parent(self): return self._parent
     88
     89      @parent.setter
     90 -    def parent(self, value): self._parent = value
     91
     92
     93
     94      @property
     95 -    def maxWidth(self): return -1
     96
     97      @maxWidth.setter
     98 -    def maxWidth(self, value): pass
     99
    100      @property
    101 -    def minWidth(self): return -1
    102
    103      @minWidth.setter
    104 -    def minWidth(self, value): pass
    105
    106
    107      @property
    108 -    def maxHeight(self): return -1
    109
    110      @maxHeight.setter
    111 -    def maxHeight(self, value): pass
    112
    113      @property
    114 -    def minHeight(self): return -1
    115
    116      @minHeight.setter
    117 -    def minHeight(self, value): pass
    118
    119
    120 -    def __str__(self): return "<span id='place%s' />" % self._name
    121