Changeset 716

Show
Ignore:
Timestamp:
01/12/05 12:54:57 (4 years ago)
Author:
paul
Message:

Fixed dListBox, dDropdownList, dComboBox, and dRadioGroup to not
invert the keys dict every time we query the key value. Used
Vladimir's patch for guidance, but implemented it using a local
Python dict, mostly because wx.RadioGroup? doesn't have a
Get/SetClientData() method. I think the difference is moot.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/AUTHORS

    r56 r716  
    1 Ed Leafe <ed@leafe.com> 
    2 Paul McNett <p@ulmcnett.com> 
     1The core authors of Dabo are: 
     2 
     3    Ed Leafe 
     4    Paul McNett 
     5 
     6 
     7The following people have submitted patches to Dabo: 
     8 
     9    John Fabiani 
     10    Vladimir Sekissov 
     11 
     12 
     13Thanks everyone for using, improving, and enjoying Dabo!! 
  • trunk/ui/uiwx/dComboBox.py

    r696 r716  
    7777        if type(val) == dict: 
    7878            self._keys = val 
     79            self._invertedKeys = dict([[v,k] for k,v in val.iteritems()]) 
    7980        else: 
    8081            raise TypeError, "Keys must be a dictionary." 
    8182             
    8283    def _getKeyValue(self): 
    83         # invert the dict so we can get the key based on current position: 
    84         inverted = dict([[v,k] for k,v in self.Keys.iteritems()]) 
    85         try: 
    86             return inverted[self.PositionValue] 
     84        # Return the current key value based on the current position value 
     85        try: 
     86            return self._invertedKeys[self.PositionValue] 
    8787        except KeyError: 
    8888            return None 
    89         
     89     
    9090    def _setKeyValue(self, val): 
    9191        # This function takes a key value, such as 10992, finds the mapped position, 
  • trunk/ui/uiwx/dDropdownList.py

    r696 r716  
    6868        if type(val) == dict: 
    6969            self._keys = val 
     70            self._invertedKeys = dict([[v,k] for k,v in val.iteritems()]) 
    7071        else: 
    7172            raise TypeError, "Keys must be a dictionary." 
    7273             
    7374    def _getKeyValue(self): 
    74         # invert the dict so we can get the key based on current position: 
    75         inverted = dict([[v,k] for k,v in self.Keys.iteritems()]) 
    76         try: 
    77             return inverted[self.PositionValue] 
     75        # Return the current key value based on the current position value 
     76        try: 
     77            return self._invertedKeys[self.PositionValue] 
    7878        except KeyError: 
    7979            return None 
    80         # (note that the above method has to make a new dict every time the KeyValue 
    81         # is accessed... possible performance bottleneck on large lists!) 
    8280         
    8381    def _setKeyValue(self, val): 
  • trunk/ui/uiwx/dListBox.py

    r696 r716  
    7070        if type(val) == dict: 
    7171            self._keys = val 
     72            self._invertedKeys = dict([[v,k] for k,v in val.iteritems()]) 
    7273        else: 
    7374            raise TypeError, "Keys must be a dictionary." 
    7475             
    7576    def _getKeyValue(self): 
    76         # invert the dict so we can get the key based on current position: 
    77         inverted = dict([[v,k] for k,v in self.Keys.iteritems()]) 
    7877        selections = self.PositionValue 
    7978        values = [] 
     
    8786        for selection in selections: 
    8887            try: 
    89                 values.append(inverted[selection]) 
     88                values.append(self._invertedKeys[selection]) 
    9089            except KeyError: 
    9190                values.append(None) 
  • trunk/ui/uiwx/dRadioGroup.py

    r696 r716  
    109109        if type(val) == dict: 
    110110            self._keys = val 
     111            self._invertedKeys = dict([[v,k] for k,v in val.iteritems()]) 
    111112        else: 
    112113            raise TypeError, "Keys must be a dictionary." 
    113114             
    114115    def _getKeyValue(self): 
    115         # invert the dict so we can get the key based on current position: 
    116         inverted = dict([[v,k] for k,v in self.Keys.iteritems()]) 
    117         try: 
    118             return inverted[self.PositionValue] 
     116        # Return the current key value based on the current position value 
     117        try: 
     118            return self._invertedKeys[self.PositionValue] 
    119119        except KeyError: 
    120120            return None 
     
    343343            print "StringValue: ", self.StringValue 
    344344            print "Value: ", self.Value 
    345             self.enableItem(42, False) 
     345            self.enable(42, False) 
    346346         
    347347    test.Test().runTest(_T)