[GRASS-SVN] r51569 - in grass/branches/releasebranch_6_4/gui/wxpython: gmodeler gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 29 08:06:36 EDT 2012


Author: martinl
Date: 2012-04-29 05:06:36 -0700 (Sun, 29 Apr 2012)
New Revision: 51569

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/frame.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_core/goutput.py
Log:
wxGUI/modeler: minor fixes (modification indicator) in python editor
              (merge r51567 from trunk)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/frame.py	2012-04-29 11:30:37 UTC (rev 51568)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gmodeler/frame.py	2012-04-29 12:06:36 UTC (rev 51569)
@@ -110,7 +110,7 @@
         self.notebook.AddPage(page = self.canvas, text=_('Model'), name = 'model')
         self.notebook.AddPage(page = self.itemPanel, text=_('Items'), name = 'items')
         self.notebook.AddPage(page = self.variablePanel, text=_('Variables'), name = 'variables')
-        self.notebook.AddPage(page = self.pythonPanel, text=_('Python script'), name = 'python')
+        self.notebook.AddPage(page = self.pythonPanel, text=_('Python editor'), name = 'python')
         self.notebook.AddPage(page = self.goutput, text=_('Command output'), name = 'output')
         wx.CallAfter(self.notebook.SetSelectionByName, 'model')
         wx.CallAfter(self.ModelChanged, False)
@@ -1450,7 +1450,7 @@
         
         self.bodyBox = wx.StaticBox(parent = self, id = wx.ID_ANY,
                                     label = " %s " % _("Python script"))
-        self.body = PyStc(parent = self)
+        self.body = PyStc(parent = self, statusbar = self.parent.GetStatusBar())
 
         self.btnRun = wx.Button(parent = self, id = wx.ID_ANY, label = _("&Run"))
         self.btnRun.SetToolTipString(_("Run python script"))
@@ -1459,7 +1459,8 @@
         self.btnSaveAs.SetToolTipString(_("Save python script to file"))
         self.Bind(wx.EVT_BUTTON, self.OnSaveAs, self.btnSaveAs)
         self.btnRefresh = wx.Button(parent = self, id = wx.ID_REFRESH)
-        self.btnRefresh.SetToolTipString(_("Refresh python script based on the model. It will discards local changes."))
+        self.btnRefresh.SetToolTipString(_("Refresh python script based on the model.\n"
+                                           "It will discards all local changes."))
         self.Bind(wx.EVT_BUTTON, self.OnRefresh, self.btnRefresh)
         
         self._layout()
@@ -1567,7 +1568,11 @@
         event.Skip()
         
     def RefreshScript(self):
-        """!Refresh Python script"""
+        """!Refresh Python script
+
+        @return True on refresh
+        @return False script hasn't been updated
+        """
         if self.body.modified:
             dlg = wx.MessageDialog(self,
                                    message = _("Python script is locally modificated. "
@@ -1579,7 +1584,7 @@
             ret = dlg.ShowModal()
             dlg.Destroy()
             if ret == wx.ID_NO:
-                return
+                return False
         
         fd = tempfile.TemporaryFile()
         WritePythonFile(fd, self.parent.GetModel())
@@ -1588,10 +1593,13 @@
         fd.close()
         
         self.body.modified = False
- 
+        
+        return True
+    
     def OnRefresh(self, event):
         """!Refresh Python script"""
-        self.RefreshScript()
+        if self.RefreshScript():
+            self.parent.SetStatusText(_('Python script is up-to-date'), 0)
         event.Skip()
         
     def IsModified(self):

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/goutput.py	2012-04-29 11:30:37 UTC (rev 51568)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/goutput.py	2012-04-29 12:06:36 UTC (rev 51569)
@@ -1161,10 +1161,11 @@
 
     Based on StyledTextCtrl_2 from wxPython demo
     """    
-    def __init__(self, parent, id = wx.ID_ANY):
+    def __init__(self, parent, id = wx.ID_ANY, statusbar = None):
         stc.StyledTextCtrl.__init__(self, parent, id)
         
         self.parent = parent
+        self.statusbar = statusbar
         
         self.modified = False # content modified ?
         
@@ -1264,6 +1265,8 @@
         """
         if not self.modified:
             self.modified = True
+            if self.statusbar:
+                self.statusbar.SetStatusText(_('Python script contains local modifications'), 0)
         
         event.Skip()
         



More information about the grass-commit mailing list