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

Source Code for Module pyforms.web.Controls.ControlBase

  1  import uuid 
2 3 -class ControlBase(object):
4 5 _value = None 6 _label = None 7 _controlHTML = "" 8
9 - def __init__(self, label = "", defaultValue = "", helptext=None):
10 self._name = "" 11 self._help = helptext 12 self._value = defaultValue 13 self._parent = 1 14 self._label = label 15 self._popupMenu = None 16 self._id = uuid.uuid4() 17 self._controlHTML = ""
18 19
20 - def initControl(self):
21 self._controlHTML = "<div id='id{0}' ><input type='text' id='{1}' /></div>".format( self._id, self._name ) 22 return self._controlHTML
23
24 - def finishEditing(self): self.updateControl()
25
26 - def updateControl(self): pass
27
28 - def changed(self): pass
29
30 - def load(self, data):
31 if 'value' in data: self.value = data['value']
32
33 - def save(self, data):
34 if self.value: data['value'] = self.value
35
36 - def valueUpdated(self, value): pass
37
38 - def show(self): pass
39
40 - def hide(self): pass
41
42 - def openPopupMenu(self, position): pass
43
44 - def addPopupSubMenuOption(self, label, options): pass
45
46 - def addPopupMenuOption(self, label, functionAction = None): pass
47
48 - def __repr__(self): return self.value
49 50 ############################################################################ 51 ############ Properties #################################################### 52 ############################################################################ 53 54 @property
55 - def help(self): return self._help.replace('\n', '&#013;') if self._help else ''
56 57 @property
58 - def enabled(self): pass
59 60 @enabled.setter
61 - def enabled(self, value): pass
62 63 ############################################################################ 64 65 @property
66 - def value(self): return self._value
67 68 @value.setter
69 - def value(self, value):
70 oldvalue = self._value 71 self._value = value 72 if oldvalue!=value: self.valueUpdated(value)
73 74 ############################################################################ 75 76 @property
77 - def label(self): return self._label
78 79 @label.setter
80 - def label(self, value): self._label = value
81 82 ############################################################################ 83 84 @property
85 - def parent(self): return self._parent
86 87 @parent.setter
88 - def parent(self, value): self._parent = value
89 90 91 92 @property
93 - def maxWidth(self): return -1
94 95 @maxWidth.setter
96 - def maxWidth(self, value): pass
97 98 @property
99 - def minWidth(self): return -1
100 101 @minWidth.setter
102 - def minWidth(self, value): pass
103 104 105 @property
106 - def maxHeight(self): return -1
107 108 @maxHeight.setter
109 - def maxHeight(self, value): pass
110 111 @property
112 - def minHeight(self): return -1
113 114 @minHeight.setter
115 - def minHeight(self, value): pass
116
117 - def __str__(self): return "<span id='place%s' />" % self._name
118 119 120 121 #### Variable connected to the Storage manager of the corrent user 122 @property
123 - def storage(self): return self._storage
124 125 @storage.setter
126 - def storage(self, value): self._storage = value
127 ####################################################### 128 129 #### This variable has the current http request ####### 130 @property
131 - def httpRequest(self): return self._httpRequest
132 133 @httpRequest.setter
134 - def httpRequest(self, value): self._httpRequest = value
135 ####################################################### 136