Changeset 3055
- Timestamp:
- 04/12/2007 11:02:11 AM (2 years ago)
- Files:
-
- branches/NateBranch/dabo/ui/uiwx/dEditBox.py (modified) (1 diff)
- branches/NateBranch/dabo/ui/uiwx/dSearchBox.py (modified) (9 diffs)
- branches/NateBranch/dabo/ui/uiwx/dTextBoxMixin.py (modified) (4 diffs)
- branches/NateBranch/tests/unitTests/ui/UIwx/Test_dSearchBox.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/NateBranch/dabo/ui/uiwx/dEditBox.py
r3053 r3055 74 74 Its the Love Boat 75 75 """ 76 76 self.TextLength = 50 77 77 self.ForceCase = "u" 78 78 branches/NateBranch/dabo/ui/uiwx/dSearchBox.py
r3050 r3055 17 17 self._cancelVisible = False 18 18 self._searchVisible = True 19 self._outOfInit = False #Remedies a problem with the memory leak for the wx20 #ShowCancelButton and ShowSearchButton properties21 #when called in constructor or initProperties22 19 23 20 preClass = wx.PreSearchCtrl … … 30 27 self.Bind(wx.EVT_SEARCHCTRL_CANCEL_BTN, self.__onWxCancelBtnPressed) 31 28 32 def _afterInit(self):33 self._outOfInit = True34 self.ShowCancelButton(self._cancelVisible)35 self.ShowSearchButton(self._searchVisible)36 tbm.dTextBoxMixin._afterInit(self)37 29 38 30 #handle events … … 53 45 menu.append(value) 54 46 55 self. Menu = menu47 self.SetMenu(menu) 56 48 57 49 … … 61 53 62 54 def _setCancelButtonVisible(self, val): 63 if val: 64 self._cancelVisible = True 55 if self._constructed(): 56 if val: 57 self._cancelVisible = True 58 else: 59 self._cancelVisible = False 60 61 self.ShowCancelButton(self._cancelVisible) 65 62 else: 66 self._cancelVisible = False 67 68 if self._outOfInit: 69 self.ShowCancelButton(self._cancelVisible) 63 self._properties["CancelButtonVisible"] = val 70 64 71 65 … … 76 70 77 71 def _setList(self, val): 78 if val == None or val == [] or val == (): 79 val = [] 80 self.SetMenu(None) 81 elif type(val) in (list, tuple): 82 self._setupMenuFromList(val) 83 self._list = val 72 if self._constructed(): 73 if val == None or val == [] or val == (): 74 self._list = [] 75 self.SetMenu(None) 76 elif type(val) in (list, tuple): 77 self._setupMenuFromList(val) 78 self._list = val 79 else: 80 raise TypeError, "List must be either a tuple, list, or None" 84 81 else: 85 raise TypeError, "List must be either a tuple, list, or None" 82 self._properties["List"] = val 83 84 def _getMenu(self): 85 return self.GetMenu() 86 86 87 87 … … 90 90 91 91 def _setSearchButtonVisible(self, val): 92 if val: 93 self._searchVisible = True 92 if self._constructed(): 93 if val: 94 self._searchVisible = True 95 else: 96 self._searchVisible = False 97 98 self.ShowSearchButton(self._searchVisible) 94 99 else: 95 self._searchVisible = False 96 97 if self._outOfInit: 98 self.ShowSearchButton(self._searchVisible) 100 self._properties["SearchButtonVisible"] = val 99 101 100 102 … … 105 107 List = property(_getList, _setList, None, 106 108 _("A dropdown list that appears right below the search button (list)")) 109 110 Menu = property(_getMenu, None, None, 111 _("Menu used to display the controls. Generated by List (dMenu)")) 107 112 108 113 SearchButtonVisible = property(_getSearchButtonVisible, _setSearchButtonVisible, None, … … 122 127 self.CancelButtonVisible = True 123 128 self.SearchButtonVisible = True 129 self.List = ("item 1", "item 2", "item 3") 124 130 125 131 def onValueChanged(self, evt): … … 143 149 def afterInit(self): 144 150 self.Value = 23.5 145 self.List = [' item 1', 'item 2']151 self.List = ['changed item 1', 'changed item 2'] 146 152 147 153 class BoolText(TestBase): branches/NateBranch/dabo/ui/uiwx/dTextBoxMixin.py
r3053 r3055 232 232 233 233 def _setTextLength(self, val): 234 if val == None: 235 self._textLength = None 236 else: 237 val = int(val) 238 if val < 1: 239 raise ValueError, 'TextLength must be a positve Integer' 240 self._textLength = val 241 self._checkTextLength() 242 243 self.unbindEvent(dEvents.KeyChar, self.__onKeyChar) 244 if self._forceCase or self._textLength: 245 self.bindEvent(dEvents.KeyChar, self.__onKeyChar) 234 if self._constructed(): 235 if val == None: 236 self._textLength = None 237 else: 238 val = int(val) 239 if val < 1: 240 raise ValueError, 'TextLength must be a positve Integer' 241 self._textLength = val 242 self._checkTextLength() 243 244 self.unbindEvent(dEvents.KeyChar, self.__onKeyChar) 245 if self._forceCase or self._textLength: 246 self.bindEvent(dEvents.KeyChar, self.__onKeyChar) 247 else: 248 self._properties["TextLength"] = val 246 249 247 250 … … 255 258 # string value of the control: 256 259 strVal = self.GetValue() 257 260 258 261 if _value is None: 259 262 if strVal == self.Application.NoneDisplay: … … 271 274 else: 272 275 dabo.ui.callAfter(self._checkForceCase) 276 277 if self._inTextLength: 278 # Value is changing internally. Don't update the oldval 279 # setting or change the type; just set the value. 280 self.SetValue(val) 281 return 282 else: 283 dabo.ui.callAfter(self._checkTextLength) 273 284 274 285 if val is None: … … 285 296 286 297 if type(_oldVal) != type(val) or _oldVal != val: 287 self._afterValueChanged() 298 self._afterValueChanged() 288 299 else: 289 300 self._properties["Value"] = val 290 291 self._checkTextLength() 301 292 302 293 303 branches/NateBranch/tests/unitTests/ui/UIwx/Test_dSearchBox.py
r3050 r3055 80 80 """List should accept lists of all lengths and properly input each element as a dMenuItem in Menu""" 81 81 testList = [] 82 testMenu = dabo.ui.dMenu()83 82 for num in range(5): 84 83 testList.append("item %s" % (num,)) … … 94 93 typeList = ([], None, ()) 95 94 for value in typeList: 96 self.testSearchBox.Menu = dabo.ui.dMenu() 95 self.testSearchBox.List = ["some", "items"] 96 self.assertNotEquals(self.testSearchBox.Menu, None) 97 97 self.testSearchBox.List = value 98 98 self.assertEquals(self.testSearchBox.List, [])
