[GRASS-SVN] r72526 - grass/trunk/gui/wxpython/tplot

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 23 03:47:40 PDT 2018


Author: lucadelu
Date: 2018-03-23 03:47:39 -0700 (Fri, 23 Mar 2018)
New Revision: 72526

Modified:
   grass/trunk/gui/wxpython/tplot/frame.py
   grass/trunk/gui/wxpython/tplot/g.gui.tplot.py
Log:
g.gui.tplot: added title,xlabel,ylabel support to command line

Modified: grass/trunk/gui/wxpython/tplot/frame.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/frame.py	2018-03-23 09:59:38 UTC (rev 72525)
+++ grass/trunk/gui/wxpython/tplot/frame.py	2018-03-23 10:47:39 UTC (rev 72526)
@@ -297,6 +297,7 @@
         self.ntb.AddPage(page=self.controlPanelLabels, text=_('Labels'),
                          name='Labels')
 
+
         # ------------Buttons on the bottom(draw,help)------------
         self.vButtPanel = wx.Panel(self.mainPanel, id=wx.ID_ANY)
         self.vButtSizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -604,7 +605,6 @@
             self.axes2d.set_ylabel(self.drawY)
         else:
             self.axes2d.set_ylabel(', '.join(self.yticksNames))
-        print(self.drawTitle)
         if self.drawTitle != '':
             self.axes2d.set_title(self.drawTitle)
         
@@ -878,9 +878,9 @@
         """Function to show help"""
         RunCommand(prog='g.manual', quiet=True, entry='g.gui.tplot')
 
-    def SetDatasets(self, rasters, vectors, coors, cats, attr):
+    def SetDatasets(self, rasters, vectors, coors, cats, attr, title, xlabel,
+                    ylabel):
         """Set the data
-        #TODO
         :param list rasters: a list of temporal raster dataset's name
         :param list vectors: a list of temporal vector dataset's name
         :param list coors: a list with x/y coordinates
@@ -921,6 +921,12 @@
         if self.datasetsR:
             self.datasetSelectR.SetValue(
                 ','.join(map(lambda x: x[0] + '@' + x[1], self.datasetsR)))
+        if title:
+            self.title.SetValue(title)
+        if xlabel:
+            self.x.SetValue(xlabel)
+        if ylabel:
+            self.y.SetValue(ylabel)
         self._redraw()
 
     def OnVectorSelected(self, event):

Modified: grass/trunk/gui/wxpython/tplot/g.gui.tplot.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/g.gui.tplot.py	2018-03-23 09:59:38 UTC (rev 72525)
+++ grass/trunk/gui/wxpython/tplot/g.gui.tplot.py	2018-03-23 10:47:39 UTC (rev 72526)
@@ -49,7 +49,6 @@
 #% required: no
 #%end
 
-
 #%option
 #% key: attr
 #% label: Name of attribute
@@ -64,6 +63,27 @@
 #%end
 
 #%option
+#% key: title
+#% label: Title for plot
+#% description: The title for the output plot
+#% required: no
+#%end
+
+#%option
+#% key: xlabel
+#% label: Label for x axis
+#% description: The x axis label for the output plot
+#% required: no
+#%end
+
+#%option
+#% key: ylabel
+#% label: Label for y axis
+#% description: The y axis label for the output plot
+#% required: no
+#%end
+
+#%option
 #% key: size
 #% type: string
 #% label: The size for output image
@@ -112,9 +132,19 @@
         elif not coords and not cats:
             gscript.warning(_("With stvds you have to use 'coordinates' or "
                               "'cats' option"))
+    title = None
+    if options['title']:
+        title = options['title']
+    xlabel = None
+    if options['xlabel']:
+        xlabel = options['xlabel']
+    ylabel = None
+    if options['ylabel']:
+        ylabel = options['ylabel']
     app = wx.App()
     frame = TplotFrame(parent=None, giface=StandaloneGrassInterface())
-    frame.SetDatasets(rasters, vectors, coords, cats, attr)
+    frame.SetDatasets(rasters, vectors, coords, cats, attr, title, xlabel,
+                      ylabel)
     if output:
         frame.OnRedraw()
         if options['size']:



More information about the grass-commit mailing list