Changeset 2898
- Timestamp:
- 03/09/07 16:47:01 (2 years ago)
- Files:
-
- trunk/dabo/ui/uiwx/dTextBox.py (modified) (7 diffs)
- trunk/tests/TestCaseTemplate.py (modified) (1 diff)
- trunk/tests/unitTests/CoverageReport.py (added)
- trunk/tests/unitTests/masterTestSuite.py (modified) (2 diffs)
- trunk/tests/unitTests/ui/UIwx/Test_dTextBox.py (added)
- trunk/tests/unitTests/ui/UIwx/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/ui/uiwx/dTextBox.py
r2789 r2898 29 29 self._forceCase = None 30 30 self._inForceCase = False 31 self._textLength = None 32 self._inTextLength = False 31 33 32 34 preClass = wx.PreTextCtrl … … 214 216 or keyChar in """,./<>?;':"[]\\{}|`~!@#$%%^&*()-_=+"""): 215 217 dabo.ui.callAfter(self.__forceCase) 216 218 dabo.ui.callAfter(self.__textLength) 219 220 def __textLength(self): 221 """If the TextLength property is set, checks the current value of the control 222 and truncates it if too long""" 223 if not isinstance(self.Value, basestring): 224 #Don't bother if it isn't a string type 225 return 226 length = self.TextLength 227 if not length: 228 return 229 230 insPos = self.InsertionPosition 231 232 self._inTextLength = True 233 if len(self.Value) > length: 234 self.Value = self.Value[:length] 235 if insPos > length: 236 self.InsertionPosition = length 237 else: 238 self.InsertionPosition = insPos 239 self.refresh() 240 self._inTextLength = False 217 241 218 242 def __forceCase(self): … … 285 309 self.__forceCase() 286 310 self.unbindEvent(dEvents.KeyChar, self.__onKeyChar) 287 if self._forceCase :311 if self._forceCase or self._textLength: 288 312 self.bindEvent(dEvents.KeyChar, self.__onKeyChar) 289 313 else: … … 369 393 def _setStrictDateEntry(self, val): 370 394 self._strictDateEntry = bool(val) 395 396 397 def _getTextLength(self): 398 return self._textLength 399 400 def _setTextLength(self, val): 401 if val == None: 402 self._textLength = None 403 else: 404 val = int(val) 405 if val < 1: 406 raise ValueError, 'TextLength must be a positve Integer' 407 self._textLength = val 408 self.__textLength() 409 410 self.unbindEvent(dEvents.KeyChar, self.__onKeyChar) 411 if self._forceCase or self._textLength: 412 self.bindEvent(dEvents.KeyChar, self.__onKeyChar) 371 413 372 414 … … 421 463 else: 422 464 dabo.ui.callAfter(self.__forceCase) 423 465 424 466 strVal = self.getStringValue(val) 425 467 _oldVal = self._oldVal = self.Value … … 440 482 else: 441 483 self._properties["Value"] = val 484 485 self.__textLength() 442 486 443 487 … … 488 532 If not strict, dates can be accepted in YYYYMMDD, YYMMDD, and MMDD format, 489 533 which will be coerced into sensible date values automatically.""")) 534 535 TextLength = property(_getTextLength, _setTextLength, None, 536 _("""The maximum length the entered text can be. (int)""")) 490 537 491 538 Value = property(_getValue, _setValue, None, trunk/tests/TestCaseTemplate.py
r2857 r2898 16 16 pass 17 17 18 def suite():19 classList = [TestCaseSample]20 return unittest.TestSuite(classList)21 22 18 if __name__ == "__main__": 23 19 unittest.main() trunk/tests/unitTests/masterTestSuite.py
r2884 r2898 17 17 18 18 import dabo 19 dabo.ui.loadUI('wx') 20 19 21 import db 20 22 import biz … … 35 37 36 38 coverage.stop() 37 coverage.report([dabo.dColors, dabo.dObject, dabo]) 39 #You can uncomment this to get test coverage on a particular module, but if you want to 40 #see the entire report for dabo, run "python CoverageReport.py". I would pipe it to a file though 41 #coverage.report([dabo.dColors, dabo.dObject, dabo]) trunk/tests/unitTests/ui/UIwx/__init__.py
r2857 r2898 12 12 13 13 #import TestCase suites and add to list here 14 14 import Test_dTextBox 15 suiteList.append(unittest.TestLoader().loadTestsFromModule(Test_dTextBox)) 15 16 16 17 #setup a suite and return it
