[GRASS-SVN] r55420 - grass/trunk/gui/wxpython/lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Mar 18 04:44:32 PDT 2013
Author: zarch
Date: 2013-03-18 04:44:32 -0700 (Mon, 18 Mar 2013)
New Revision: 55420
Modified:
grass/trunk/gui/wxpython/lmgr/giface.py
Log:
Improve the interaction with Layer and LayerList objects
Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py 2013-03-18 10:56:20 UTC (rev 55419)
+++ grass/trunk/gui/wxpython/lmgr/giface.py 2013-03-18 11:44:32 UTC (rev 55420)
@@ -17,6 +17,7 @@
from grass.pydispatch.signal import Signal
+
class Layer(object):
"""!@implements core::giface::Layer
@@ -29,17 +30,31 @@
def __getattr__(self, name):
return self._pydata[0][name]
+ def __dir__(self):
+ return self._pydata[0].keys()
+ def __repr__(self):
+ return self.maplayer.name
+
+
class LayerList(object):
"""!@implements core.giface.Layer"""
def __init__(self, tree):
self._tree = tree
-# def __iter__(self):
-# """!Iterates over the contents of the list."""
-# for in :
-# yield
+ def __iter__(self):
+ """!Iterates over the contents of the list."""
+ for item in self._tree.GetSelectedLayer(multi=True):
+ yield Layer(self._tree.GetPyData(item))
+ def __getitem__(self, index):
+ """!Select a layer from the LayerList using the index."""
+ return [l for l in self][index]
+
+ def __repr__(self):
+ """!Return a representation of the object."""
+ return "LayerList(%r)" % [layer for layer in self]
+
def GetSelectedLayers(self, checkedOnly=True):
items = self._tree.GetSelectedLayer(multi=True,
checkedOnly=checkedOnly)
More information about the grass-commit
mailing list