[GRASS-SVN] r51567 - in grass/trunk/gui/wxpython: gmodeler gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 29 07:28:04 EDT 2012


Author: martinl
Date: 2012-04-29 04:28:04 -0700 (Sun, 29 Apr 2012)
New Revision: 51567

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


Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2012-04-29 10:38:19 UTC (rev 51566)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2012-04-29 11:28:04 UTC (rev 51567)
@@ -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)
@@ -1449,7 +1449,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"))
@@ -1458,7 +1458,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()
@@ -1566,7 +1567,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. "
@@ -1578,7 +1583,7 @@
             ret = dlg.ShowModal()
             dlg.Destroy()
             if ret == wx.ID_NO:
-                return
+                return False
         
         fd = tempfile.TemporaryFile()
         WritePythonFile(fd, self.parent.GetModel())
@@ -1587,10 +1592,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/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py	2012-04-29 10:38:19 UTC (rev 51566)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py	2012-04-29 11:28:04 UTC (rev 51567)
@@ -1164,10 +1164,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 ?
         
@@ -1267,6 +1268,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