dabo Commit
Revision 1389
Date: 2005-09-28 22:39:44 -0700 (Wed, 28 Sep 2005)
Author: paul

Changed:
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
Fixed the list editors in dGrid, and added a column that uses list editors
to the test.

Ed, I also verified that it appears to work as-is in the Designer.



Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2005-09-28 22:21:41 UTC (rev 1388)
+++ trunk/dabo/ui/uiwx/dGrid.py 2005-09-29 05:39:44 UTC (rev 1389)
@@ -501,11 +501,22 @@
                edClass = self.getEditorClassForRow(row)
                attr = self._gridColAttr.Clone()
                if edClass:
-                       e = edClass()
-                       attr.SetEditor(e)
+                       kwargs = {}
+                       if edClass in (wx.grid.GridCellChoiceEditor,):
+                               kwargs["choices"] = 
self.getListEditorChoicesForRow(row)
+                       editor = edClass(**kwargs)
+                       attr.SetEditor(editor)
                self._gridColAttr = attr
 
 
+       def getListEditorChoicesForRow(self, row):
+               """Return the list of choices for the list editor for the given 
row."""
+               choices = self.CustomListEditorChoices.get(row)
+               if choices is None:
+                       choices = self.ListEditorChoices
+               return choices
+
+
        def getEditorClassForRow(self, row):
                """Return the cell editor class for the passed row."""
                d = self.CustomEditors
@@ -3136,9 +3147,9 @@
 
 class _dGrid_test(dGrid):
        def initProperties(self):
-               self.DataSet = [{"name" : "Ed Leafe", "age" : 47, "coder" :  
True},
-                               {"name" : "Mike Leafe", "age" : 18, "coder" :  
False},
-                               {"name" : "Dan Leafe", "age" : 13, "coder" :  
False} ]
+               self.DataSet = [{"name" : "Ed Leafe", "age" : 47, "coder" :  
True, "color": "brown"},
+                               {"name" : "Mike Leafe", "age" : 18, "coder" :  
False, "color": "purple"},
+                               {"name" : "Dan Leafe", "age" : 13, "coder" :  
False, "color": "green"}]
                self.Width = 360
                self.Height = 150
                self.Editable = True
@@ -3173,6 +3184,14 @@
                                Sortable=True, Searchable=False, Editable=True)
                self.addColumn(col)
 
+               col = dColumn(self, Name="Color", Order=40, DataField="color",
+                               DataType="string", Width=40, Caption="Favorite 
Color",
+                               Sortable=True, Searchable=False, Editable=True)
+               self.addColumn(col)
+
+               col.ListEditorChoices = ["green", "brown", "purple"]
+               col.CustomEditorClass = col.listEditorClass
+
                col.HeaderVerticalAlignment = "Bottom"
                col.HeaderHorizontalAlignment = "Right"
                col.HeaderForegroundColor = "brown"




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to