[GRASS-SVN] r71186 - grass/trunk/gui/wxpython/datacatalog
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 14 20:14:58 PDT 2017
Author: annakrat
Date: 2017-06-14 20:14:57 -0700 (Wed, 14 Jun 2017)
New Revision: 71186
Modified:
grass/trunk/gui/wxpython/datacatalog/tree.py
Log:
wxGUI/datacatalog: add convenient functions to context menu
Modified: grass/trunk/gui/wxpython/datacatalog/tree.py
===================================================================
--- grass/trunk/gui/wxpython/datacatalog/tree.py 2017-06-14 07:29:46 UTC (rev 71185)
+++ grass/trunk/gui/wxpython/datacatalog/tree.py 2017-06-15 03:14:57 UTC (rev 71186)
@@ -842,6 +842,34 @@
self.changeLocation.emit(mapset=self.selected_mapset.label, location=self.selected_location.label)
self.ExpandCurrentMapset()
+ def OnMetadata(self, event):
+ """Show metadata of any raster/vector/3draster"""
+ def done(event):
+ gscript.try_remove(gisrc)
+
+ if self.selected_type.label == 'raster':
+ cmd = ['r.info']
+ elif self.selected_type.label == 'vector':
+ cmd = ['v.info']
+ elif self.selected_type.label == 'raster_3d':
+ cmd = ['r3.info']
+ cmd.append('map=%s@%s' % (self.selected_layer.label, self.selected_mapset.label))
+
+ gisrc, env = gscript.create_environment(
+ gisenv()['GISDBASE'],
+ self.selected_location.label, self.selected_mapset.label)
+ # print output to command log area
+ # temp gisrc file must be deleted onDone
+ self._giface.RunCmd(cmd, env=env, onDone=done)
+
+ def OnCopyName(self, event):
+ """Copy layer name to clipboard"""
+ if wx.TheClipboard.Open():
+ do = wx.TextDataObject()
+ do.SetText('%s@%s' % (self.selected_layer.label, self.selected_mapset.label))
+ wx.TheClipboard.SetData(do)
+ wx.TheClipboard.Close()
+
def Filter(self, text):
"""Filter tree based on name and type."""
text = text.strip()
@@ -905,6 +933,10 @@
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnCopyMap, item)
+ item = wx.MenuItem(menu, wx.NewId(), _("Copy &name"))
+ menu.AppendItem(item)
+ self.Bind(wx.EVT_MENU, self.OnCopyName, item)
+
item = wx.MenuItem(menu, wx.NewId(), _("&Paste"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnPasteMap, item)
@@ -921,13 +953,18 @@
self.Bind(wx.EVT_MENU, self.OnRenameMap, item)
item.Enable(currentMapset)
+ menu.AppendSeparator()
+
if not isinstance(self._giface, StandaloneGrassInterface) and \
self.selected_location.label == genv['LOCATION_NAME']:
- menu.AppendSeparator()
item = wx.MenuItem(menu, wx.NewId(), _("&Display layer"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnDisplayLayer, item)
+ item = wx.MenuItem(menu, wx.NewId(), _("Show &metadata"))
+ menu.AppendItem(item)
+ self.Bind(wx.EVT_MENU, self.OnMetadata, item)
+
self.PopupMenu(menu)
menu.Destroy()
More information about the grass-commit
mailing list