[GRASS-SVN] r53710 - grass/trunk/gui/wxpython/wxplot
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Nov 6 07:26:31 PST 2012
Author: martinl
Date: 2012-11-06 07:26:31 -0800 (Tue, 06 Nov 2012)
New Revision: 53710
Modified:
grass/trunk/gui/wxpython/wxplot/base.py
grass/trunk/gui/wxpython/wxplot/dialogs.py
grass/trunk/gui/wxpython/wxplot/profile.py
Log:
wxGUI/profiler: fix CVS export
(merge r53696 & r53706 from relbr64)
Modified: grass/trunk/gui/wxpython/wxplot/base.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/base.py 2012-11-06 15:25:16 UTC (rev 53709)
+++ grass/trunk/gui/wxpython/wxplot/base.py 2012-11-06 15:26:31 UTC (rev 53710)
@@ -515,14 +515,13 @@
"""!Set custom text values for profile title and axis labels.
"""
dlg = TextDialog(parent = self, id = wx.ID_ANY,
- plottype = self.plottype,
- title = _('Histogram text settings'))
-
+ plottype = self.plottype,
+ title = _('Text settings'))
+
btnval = dlg.ShowModal()
if btnval == wx.ID_SAVE or btnval == wx.ID_OK or btnval == wx.ID_CANCEL:
dlg.Destroy()
-
-
+
def PlotOptions(self, event):
"""!Set various profile options, including: line width, color,
style; marker size, color, fill, and style; grid and legend
Modified: grass/trunk/gui/wxpython/wxplot/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/dialogs.py 2012-11-06 15:25:16 UTC (rev 53709)
+++ grass/trunk/gui/wxpython/wxplot/dialogs.py 2012-11-06 15:26:31 UTC (rev 53710)
@@ -11,7 +11,7 @@
- dialogs::TextDialog
- dialogs::OptDialog
-(C) 2011 by the GRASS Development Team
+(C) 2011-2012 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
Modified: grass/trunk/gui/wxpython/wxplot/profile.py
===================================================================
--- grass/trunk/gui/wxpython/wxplot/profile.py 2012-11-06 15:25:16 UTC (rev 53709)
+++ grass/trunk/gui/wxpython/wxplot/profile.py 2012-11-06 15:26:31 UTC (rev 53710)
@@ -7,7 +7,7 @@
- profile::ProfileFrame
- profile::ProfileToolbar
-(C) 2011 by the GRASS Development Team
+(C) 2011-2012 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -22,7 +22,6 @@
import wx
import wx.lib.plot as plot
-from core.gcmd import GWarning
import grass.script as grass
try:
@@ -38,7 +37,7 @@
from wxplot.base import BasePlotFrame, PlotIcons
from gui_core.toolbars import BaseToolbar, BaseIcons
from wxplot.dialogs import ProfileRasterDialog, PlotStatsFrame
-from core.gcmd import RunCommand
+from core.gcmd import RunCommand, GWarning, GError, GMessage
class ProfileFrame(BasePlotFrame):
"""!Mainframe for displaying profile of one or more raster maps. Uses wx.lib.plot.
@@ -327,31 +326,48 @@
def SaveProfileToFile(self, event):
"""!Save r.profile data to a csv file
"""
- wildcard = _("Comma separated value (*.csv)|*.csv")
-
dlg = wx.FileDialog(parent = self,
- message = _("Path and prefix (for raster name) to save profile values..."),
+ message = _("Choose prefix for file(s) where to save profile values..."),
defaultDir = os.getcwd(),
- defaultFile = "", wildcard = wildcard, style = wx.SAVE)
+ wildcard = _("Comma separated value (*.csv)|*.csv"), style = wx.SAVE)
+ pfile = []
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
-
for r in self.rasterList:
- pfile = path+'_'+str(r['name'])+'.csv'
+ pfile.append(path + '_' + str(r.replace('@', '_')) + '.csv')
+ if os.path.exists(pfile[-1]):
+ dlgOv = wx.MessageDialog(self,
+ message = _("File <%s> already exists. "
+ "Do you want to overwrite this file?") % pfile[-1],
+ caption = _("Overwrite file?"),
+ style = wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+ if dlgOv.ShowModal() != wx.ID_YES:
+ pfile.pop()
+ dlgOv.Destroy()
+ continue
+
try:
- file = open(pfile, "w")
- except IOError:
- wx.MessageBox(parent = self,
- message = _("Unable to open file <%s> for writing.") % pfile,
- caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
- return False
+ fd = open(pfile[-1], "w")
+ except IOError, e:
+ GError(parent = self,
+ message = _("Unable to open file <%s> for writing.\n"
+ "Reason: %s") % (pfile[-1], e))
+ dlg.Destroy()
+ return
+
for datapair in self.raster[r]['datalist']:
- file.write('%d,%d\n' % (float(datapair[0]),float(datapair[1])))
-
- file.close()
-
+ fd.write('%d,%d\n' % (float(datapair[0]),float(datapair[1])))
+
+ fd.close()
+
dlg.Destroy()
+ if pfile:
+ message = _("%d files created:\n%s") % (len(pfile), '\n'.join(pfile))
+ else:
+ message = _("No files generated.")
+ GMessage(parent = self, message = message)
+
def OnStats(self, event):
"""!Displays regression information in messagebox
"""
More information about the grass-commit
mailing list