[GRASS-SVN] r58185 - grass/trunk/gui/wxpython/gmodeler

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Nov 10 04:31:13 PST 2013


Author: martinl
Date: 2013-11-10 04:31:13 -0800 (Sun, 10 Nov 2013)
New Revision: 58185

Modified:
   grass/trunk/gui/wxpython/gmodeler/dialogs.py
   grass/trunk/gui/wxpython/gmodeler/frame.py
Log:
wxGUI/gmodeler: fix defining items in the loop (including order change)

Modified: grass/trunk/gui/wxpython/gmodeler/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/dialogs.py	2013-11-10 06:16:40 UTC (rev 58184)
+++ grass/trunk/gui/wxpython/gmodeler/dialogs.py	2013-11-10 12:31:13 UTC (rev 58185)
@@ -408,10 +408,11 @@
                                     value = shape.GetText())
         
         self.itemList = ItemCheckListCtrl(parent = self.panel,
-                                          window = self,
                                           columns = [_("Name"),
                                                      _("Command")],
-                                          shape = shape)
+                                          shape = shape,
+                                          frame = parent)
+        
         self.itemList.Populate(self.parent.GetModel().GetItems())
         
         self.btnCancel = wx.Button(parent = self.panel, id = wx.ID_CANCEL)
@@ -582,7 +583,7 @@
                     listmix.ListCtrlAutoWidthMixin,
 #                    listmix.TextEditMixin,
                     listmix.ColumnSorterMixin):
-    def __init__(self, parent, columns, id = wx.ID_ANY,
+    def __init__(self, parent, columns, frame, id = wx.ID_ANY,
                  style = wx.LC_REPORT | wx.BORDER_NONE |
                  wx.LC_SORT_ASCENDING |wx.LC_HRULES |
                  wx.LC_VRULES, **kwargs):
@@ -590,10 +591,7 @@
         self.parent = parent
         self.columns = columns
         self.shape = None
-        try:
-            self.frame  = parent.parent
-        except AttributeError:
-            self.frame = None
+        self.frame  = frame
         
         wx.ListCtrl.__init__(self, parent, id = id, style = style, **kwargs)
         listmix.ListCtrlAutoWidthMixin.__init__(self)
@@ -755,11 +753,11 @@
         menu.Destroy()
 
 class ItemListCtrl(ModelListCtrl):
-    def __init__(self, parent, columns, disablePopup = False, **kwargs):
+    def __init__(self, parent, columns, frame, disablePopup = False, **kwargs):
         """!List of model actions"""
         self.disablePopup = disablePopup
-                
-        ModelListCtrl.__init__(self, parent, columns, **kwargs)
+
+        ModelListCtrl.__init__(self, parent, columns, frame, **kwargs)
         self.SetColumnWidth(1, 100)
         self.SetColumnWidth(2, 65)
         
@@ -782,7 +780,8 @@
                 else:
                     shapeItems = map(lambda x: x.GetId(), self.shape.GetItems()['if'])
             else:
-                shapeItems = map(lambda x: x.GetId(), self.shape.GetItems())
+                shapeItems = map(lambda x: x.GetId(),
+                                 self.shape.GetItems(self.frame.GetModel().GetItems(objType=ModelAction)))
         else:
             shapeItems = list()
         
@@ -930,11 +929,12 @@
         self.Populate(model.GetItems(objType=ModelAction))
         
 class ItemCheckListCtrl(ItemListCtrl, listmix.CheckListCtrlMixin):
-    def __init__(self, parent, shape, columns, window = None, **kwargs):
+    def __init__(self, parent, shape, columns, frame, **kwargs):
         self.parent = parent
-        self.window = window
+        self.frame  = frame
         
-        ItemListCtrl.__init__(self, parent, columns, disablePopup = True, **kwargs)
+        ItemListCtrl.__init__(self, parent, columns, frame,
+                              disablePopup = True, **kwargs)
         listmix.CheckListCtrlMixin.__init__(self)
         self.SetColumnWidth(0, 100)
         

Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2013-11-10 06:16:40 UTC (rev 58184)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2013-11-10 12:31:13 UTC (rev 58185)
@@ -1122,16 +1122,17 @@
             dlg.CentreOnParent()
             if dlg.ShowModal() == wx.ID_OK:
                 shape.SetText(dlg.GetCondition())
+                model = self.frame.GetModel()
+                ids = dlg.GetItems()
                 alist = list()
-                ids = dlg.GetItems()
                 for aId in ids['unchecked']:
-                    action = self.frame.GetModel().GetItem(aId)
+                    action = model.GetItem(aId, objType=ModelAction)
                     action.UnSetBlock(shape)
                 for aId in ids['checked']:
-                    action = self.frame.GetModel().GetItem(aId)
+                    action = model.GetItem(aId, objType=ModelAction)
                     action.SetBlock(shape)
                     if action:
-                        alist.append(action)
+                        alist.append(aId)
                 shape.SetItems(alist)
                 self.frame.DefineLoop(shape)
                 self.frame.SetStatusText(shape.GetLog(), 0)
@@ -1145,18 +1146,17 @@
             if dlg.ShowModal() == wx.ID_OK:
                 shape.SetText(dlg.GetCondition())
                 model = self.frame.GetModel()
-                modelActions = model.GetItems(objType=ModelAction)
                 ids = dlg.GetItems()
                 for b in ids.keys():
                     alist = list()
-                    for idx in ids[b]['unchecked']:
-                        action = modelActions[idx]
+                    for aId in ids[b]['unchecked']:
+                        action = model.GetItem(aId, objType=ModelAction)
                         action.UnSetBlock(shape)
-                    for idx in ids[b]['checked']:
-                        action = modelActions[idx]
+                    for aId in ids[b]['checked']:
+                        action = model.GetItem(aId, objType=ModelAction)
                         action.SetBlock(shape)
                         if action:
-                            alist.append(action)
+                            alist.append(aId)
                     shape.SetItems(alist, branch = b)
                 self.frame.DefineCondition(shape)
             self.frame.GetCanvas().Refresh()
@@ -1328,7 +1328,8 @@
         
         self.list = VariableListCtrl(parent = self,
                                      columns = [_("Name"), _("Data type"),
-                                                _("Default value"), _("Description")])
+                                                _("Default value"), _("Description")],
+                                     frame = self.parent)
         
         # add new category
         self.addBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
@@ -1473,7 +1474,8 @@
         
         self.list = ItemListCtrl(parent = self,
                                  columns = [_("Name"), _("In loop"),
-                                            _("Command")])
+                                            _("Command")],
+                                 frame = self.parent)
         
         self.btnMoveUp = wx.Button(parent=self, id=wx.ID_UP)
         self.btnMoveDown = wx.Button(parent=self, id=wx.ID_DOWN)



More information about the grass-commit mailing list