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

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 26 09:13:12 PDT 2014


Author: annakrat
Date: 2014-06-26 09:13:12 -0700 (Thu, 26 Jun 2014)
New Revision: 60983

Modified:
   grass/trunk/gui/wxpython/tplot/frame.py
Log:
wxGUI/tplot: use one text field for coordinates instead of two, it is easier to input coordinates from map display

Modified: grass/trunk/gui/wxpython/tplot/frame.py
===================================================================
--- grass/trunk/gui/wxpython/tplot/frame.py	2014-06-26 15:24:21 UTC (rev 60982)
+++ grass/trunk/gui/wxpython/tplot/frame.py	2014-06-26 16:13:12 UTC (rev 60983)
@@ -38,8 +38,9 @@
 from core.utils import _
 
 import grass.temporal as tgis
-from core.gcmd import GError, GException, RunCommand
+from core.gcmd import GMessage, GError, GException, RunCommand
 from gui_core import gselect
+from core import globalvar
 from grass.pygrass.vector.geometry import Point
 from grass.pygrass.raster import RasterRow
 from collections import OrderedDict
@@ -121,35 +122,30 @@
         gridSizer = wx.GridBagSizer(hgap=5, vgap=5)
 
         self.datasetSelect = gselect.Select(parent=self.panel, id=wx.ID_ANY,
-                                            type='strds', multiple=True, size=(150, -1))
+                                            size=globalvar.DIALOG_GSELECT_SIZE,
+                                            type='strds', multiple=True)
         self.drawButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Draw"))
         self.drawButton.Bind(wx.EVT_BUTTON, self.OnRedraw)
         self.helpButton = wx.Button(self.panel, id=wx.ID_ANY, label=_("Help"))
         self.helpButton.Bind(wx.EVT_BUTTON, self.OnHelp)
 
-        self.xcoor = wx.StaticText(parent=self.panel, id=wx.ID_ANY,
-                                   label=_('Insert longitude (x) coordinate'))
+        self.coor = wx.StaticText(parent=self.panel, id=wx.ID_ANY,
+                                  label=_('X and Y coordinates separated by comma:'))
 
-        self.xcoorval = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY,
-                                    size=(150, -1))
-        self.ycoor = wx.StaticText(parent=self.panel, id=wx.ID_ANY,
-                                   label=_('Insert latitude (y) coordinate'))
+        self.coorval = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY)
+        self.coorval.SetToolTipString(_("Coordinates can be obtained for example "
+                                        "by right-clicking on Map Display."))
 
-        self.ycoorval = wx.TextCtrl(parent=self.panel, id=wx.ID_ANY,
-                                    size=(150, -1))
-
         gridSizer.Add(wx.StaticText(self.panel, id=wx.ID_ANY,
-                                    label=_("Select space time dataset(s):")),
+                                    label=_("Select space time raster dataset(s):")),
                       pos=(0, 0), flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL)
         gridSizer.Add(self.datasetSelect, pos=(1, 0), flag=wx.EXPAND)
 
-        gridSizer.Add(self.xcoor, pos=(2, 0), flag=wx.EXPAND)
-        gridSizer.Add(self.ycoor, pos=(2, 1), flag=wx.EXPAND)
+        gridSizer.Add(self.coor, pos=(2, 0), flag=wx.EXPAND)
 
-        gridSizer.Add(self.xcoorval, pos=(3, 0), flag=wx.EXPAND)
-        gridSizer.Add(self.ycoorval, pos=(3, 1), flag=wx.EXPAND)
-        gridSizer.Add(self.drawButton, pos=(3, 2), flag=wx.EXPAND)
-        gridSizer.Add(self.helpButton, pos=(3, 3), flag=wx.EXPAND)
+        gridSizer.Add(self.coorval, pos=(3, 0), flag=wx.EXPAND)
+        gridSizer.Add(self.drawButton, pos=(3, 1), flag=wx.EXPAND)
+        gridSizer.Add(self.helpButton, pos=(3, 2), flag=wx.EXPAND)
 
         self.vbox.Add(gridSizer, proportion=0, flag=wx.EXPAND | wx.ALL,
                       border=10)
@@ -286,8 +282,12 @@
             return
 
         self.datasets = datasets
-        coors = [self.xcoorval.GetValue().strip(),
-                 self.ycoorval.GetValue().strip()]
+        try:
+            coordx, coordy = self.coorval.GetValue().split(',')
+            coordx, coordy = float(coordx), float(coordy)
+        except ValueError:
+            GMessage(_("Incorrect format of coordinates, should be: x,y"))
+        coors = [coordx, coordy]
         if coors:
             try:
                 self.poi = Point(float(coors[0]), float(coors[1]))
@@ -394,8 +394,7 @@
         self.dpi = dpi
         self.datasetSelect.SetValue(','.join(map(lambda x: x[0] + '@' + x[1],
                                                  datasets)))
-        self.xcoorval.SetValue(str(coors[0]))
-        self.ycoorval.SetValue(str(coors[1]))
+        self.coorval.SetValue(','.join(coors))
         self._redraw()
 
 



More information about the grass-commit mailing list