浏览代码

wxGUI: LayerList - add __len__()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64856 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 年之前
父节点
当前提交
3ff0104741
共有 2 个文件被更改,包括 4 次插入1 次删除
  1. 1 1
      gui/wxpython/gui_core/forms.py
  2. 3 0
      gui/wxpython/lmgr/giface.py

+ 1 - 1
gui/wxpython/gui_core/forms.py

@@ -1206,7 +1206,7 @@ class CmdPanel(wx.Panel):
                                 extraItems = {_('Graphical Modeler') : self._giface.GetLayerList(p.get('prompt'))}
                             else:
                                 layers = self._giface.GetLayerList()
-                                if layers:
+                                if len(layers) > 0:
                                     mapList = []
                                     extraItems = {_('Map Display') : mapList}
                                     for layer in layers:

+ 3 - 0
gui/wxpython/lmgr/giface.py

@@ -47,6 +47,9 @@ class LayerList(object):
     def __init__(self, tree):
         self._tree = tree
 
+    def __len__(self):
+        return len([layer for layer in self])
+        
     def __iter__(self):
         """Iterates over the contents of the list."""
         item = self._tree.GetFirstChild(self._tree.root)[0]