Преглед изворни кода

wxGUI: clean up message handling related to GConsole (co-author: wenzeslaus)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58086 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová пре 11 година
родитељ
комит
a84d5ddc4f

+ 23 - 37
gui/wxpython/core/gconsole.py

@@ -43,6 +43,7 @@ from core.utils import _
 from gui_core.forms import GUI
 from gui_core.forms import GUI
 from core.debug import Debug
 from core.debug import Debug
 from core.settings import UserSettings
 from core.settings import UserSettings
+from core.giface import Notification
 
 
 
 
 wxCmdOutput, EVT_CMD_OUTPUT = NewEvent()
 wxCmdOutput, EVT_CMD_OUTPUT = NewEvent()
@@ -115,7 +116,7 @@ class CmdThread(threading.Thread):
         os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'
         os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'
         while True:
         while True:
             requestId, args, kwds = self.requestQ.get()
             requestId, args, kwds = self.requestQ.get()
-            for key in ('callable', 'onDone', 'onPrepare', 'userData'):
+            for key in ('callable', 'onDone', 'onPrepare', 'userData', 'notification'):
                 if key in kwds:
                 if key in kwds:
                     vars()[key] = kwds[key]
                     vars()[key] = kwds[key]
                     del kwds[key]
                     del kwds[key]
@@ -139,7 +140,8 @@ class CmdThread(threading.Thread):
 
 
                 # run command
                 # run command
                 event = wxCmdRun(cmd=args[0],
                 event = wxCmdRun(cmd=args[0],
-                                 pid=requestId)
+                                 pid=requestId,
+                                 notification=vars()['notification'])
 
 
                 wx.PostEvent(self.receiver, event)
                 wx.PostEvent(self.receiver, event)
 
 
@@ -199,7 +201,8 @@ class CmdThread(threading.Thread):
                                   time=requestTime,
                                   time=requestTime,
                                   pid=requestId,
                                   pid=requestId,
                                   onDone=vars()['onDone'],
                                   onDone=vars()['onDone'],
-                                  userData=vars()['userData'])
+                                  userData=vars()['userData'],
+                                  notification=vars()['notification'])
 
 
                 # send event
                 # send event
                 wx.PostEvent(self.receiver, event)
                 wx.PostEvent(self.receiver, event)
@@ -333,13 +336,6 @@ gWriteError, EVT_WRITE_ERROR = NewEvent()
 # Attribute cmd contains command (as a list).
 # Attribute cmd contains command (as a list).
 gIgnoredCmdRun, EVT_IGNORED_CMD_RUN = NewEvent()
 gIgnoredCmdRun, EVT_IGNORED_CMD_RUN = NewEvent()
 
 
-# Occurs when important command is called.
-# Determined by switchPage and priority parameters of GConsole.RunCmd()
-# currently used only for Layer Manager
-# because others (forms and gmodeler) just wants to see all commands
-# (because commands are the main part of their work)
-gImportantCmdRun, EVT_IMPORTANT_CMD_RUN = NewEvent()
-
 
 
 class GConsole(wx.EvtHandler):
 class GConsole(wx.EvtHandler):
     """!
     """!
@@ -395,29 +391,26 @@ class GConsole(wx.EvtHandler):
                 sys.stderr = sys.__stderr__
                 sys.stderr = sys.__stderr__
 
 
     def WriteLog(self, text, style=None, wrap=None,
     def WriteLog(self, text, style=None, wrap=None,
-                 switchPage=False, priority=1):
+                 notification=Notification.HIGHLIGHT):
         """!Generic method for writing log message in
         """!Generic method for writing log message in
         given style
         given style
 
 
         @param line text line
         @param line text line
-        @param switchPage for backward compatibility
-        (replace by priority: False=1, True=2)
-        @param priority priority of this message
-        (0=no priority, 1=normal, 2=medium, 3=high)
+        @param notification form of notification
         """
         """
         event = gWriteLog(text=text, wrap=wrap,
         event = gWriteLog(text=text, wrap=wrap,
-                          switchPage=switchPage, priority=priority)
+                          notification=notification)
         wx.PostEvent(self, event)
         wx.PostEvent(self, event)
 
 
-    def WriteCmdLog(self, line, pid=None, switchPage=True):
+    def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
         """!Write message in selected style
         """!Write message in selected style
 
 
         @param line message to be printed
         @param line message to be printed
         @param pid process pid or None
         @param pid process pid or None
-        @param switchPage True to switch page
+        @param notification form of notification
         """
         """
         event = gWriteCmdLog(line=line, pid=pid,
         event = gWriteCmdLog(line=line, pid=pid,
-                             switchPage=switchPage)
+                             notification=notification)
         wx.PostEvent(self, event)
         wx.PostEvent(self, event)
 
 
     def WriteWarning(self, line):
     def WriteWarning(self, line):
@@ -430,8 +423,8 @@ class GConsole(wx.EvtHandler):
         event = gWriteError(line=line)
         event = gWriteError(line=line)
         wx.PostEvent(self, event)
         wx.PostEvent(self, event)
 
 
-    def RunCmd(self, command, compReg=True, switchPage=False, skipInterface=False,
-               onDone=None, onPrepare=None, userData=None, priority=1):
+    def RunCmd(self, command, compReg=True, skipInterface=False,
+               onDone=None, onPrepare=None, userData=None, notification=Notification.MAKE_VISIBLE):
         """!Run command typed into console command prompt (GPrompt).
         """!Run command typed into console command prompt (GPrompt).
 
 
         @todo Document the other event.
         @todo Document the other event.
@@ -443,13 +436,9 @@ class GConsole(wx.EvtHandler):
         (according to ignoredCmdPattern) is run.
         (according to ignoredCmdPattern) is run.
         For example, see layer manager which handles d.* on its own.
         For example, see layer manager which handles d.* on its own.
 
 
-        @todo replace swichPage and priority by parameter 'silent' or 'important'
-        also possible solution is RunCmdSilently and RunCmdWithoutNotifyingAUser
-
         @param command command given as a list (produced e.g. by utils.split())
         @param command command given as a list (produced e.g. by utils.split())
         @param compReg True use computation region
         @param compReg True use computation region
-        @param switchPage switch to output page
-        @param priority command importance - possible replacement for switchPage
+        @param notification form of notification
         @param skipInterface True to do not launch GRASS interface
         @param skipInterface True to do not launch GRASS interface
         parser when command has no arguments given
         parser when command has no arguments given
         @param onDone function to be called when command is finished
         @param onDone function to be called when command is finished
@@ -527,13 +516,6 @@ class GConsole(wx.EvtHandler):
                         print >> sys.stderr, e
                         print >> sys.stderr, e
                     return
                     return
 
 
-                # documenting old behavior/implementation:
-                # switch and focus if required
-                # important commad
-                # TODO: add also user data, cmd, ... to the event?
-                importantEvent = gImportantCmdRun()
-                wx.PostEvent(self, importantEvent)
-
                 # activate computational region (set with g.region)
                 # activate computational region (set with g.region)
                 # for all non-display commands.
                 # for all non-display commands.
                 if compReg:
                 if compReg:
@@ -547,7 +529,8 @@ class GConsole(wx.EvtHandler):
                                       stderr=self.cmdStdErr,
                                       stderr=self.cmdStdErr,
                                       onDone=onDone, onPrepare=onPrepare,
                                       onDone=onDone, onPrepare=onPrepare,
                                       userData=userData,
                                       userData=userData,
-                                      env=os.environ.copy())
+                                      env=os.environ.copy(),
+                                      notification=notification)
                 self.cmdOutputTimer.Start(50)
                 self.cmdOutputTimer.Start(50)
 
 
                 # deactivate computational region and return to display settings
                 # deactivate computational region and return to display settings
@@ -572,7 +555,8 @@ class GConsole(wx.EvtHandler):
                                       stdout=self.cmdStdOut,
                                       stdout=self.cmdStdOut,
                                       stderr=self.cmdStdErr,
                                       stderr=self.cmdStdErr,
                                       onDone=onDone, onPrepare=onPrepare,
                                       onDone=onDone, onPrepare=onPrepare,
-                                      userData=userData)
+                                      userData=userData,
+                                      notification=notification)
             self.cmdOutputTimer.Start(50)
             self.cmdOutputTimer.Start(50)
 
 
     def GetLog(self, err=False):
     def GetLog(self, err=False):
@@ -598,7 +582,8 @@ class GConsole(wx.EvtHandler):
 
 
     def OnCmdRun(self, event):
     def OnCmdRun(self, event):
         """!Run command"""
         """!Run command"""
-        self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
+        self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)),
+                         notification=event.notification)
         event.Skip()
         event.Skip()
 
 
     def OnCmdDone(self, event):
     def OnCmdDone(self, event):
@@ -628,7 +613,8 @@ class GConsole(wx.EvtHandler):
         else:
         else:
             msg = _('Command finished')
             msg = _('Command finished')
 
 
-        self.WriteCmdLog('(%s) %s (%s)' % (str(time.ctime()), msg, stime))
+        self.WriteCmdLog('(%s) %s (%s)' % (str(time.ctime()), msg, stime),
+                         notification=event.notification)
 
 
         if event.onDone:
         if event.onDone:
             event.onDone(cmd=event.cmd, returncode=event.returncode)
             event.onDone(cmd=event.cmd, returncode=event.returncode)

+ 25 - 17
gui/wxpython/core/giface.py

@@ -16,9 +16,6 @@ This program is free software under the GNU General Public License
 """
 """
 
 
 import os
 import os
-from core.gconsole import GConsole, \
-    EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, EVT_CMD_RUN, EVT_CMD_DONE, \
-    EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
 from core.utils import _
 from core.utils import _
 
 
 import grass.script as grass
 import grass.script as grass
@@ -29,6 +26,19 @@ from grass.pydispatch.signal import Signal
 #pylint: disable=R0921
 #pylint: disable=R0921
 
 
 
 
+class Notification:
+    """!Enum class for notifications suggestions.
+
+    Can be used for log messages, commands, warnings, errors.
+    The value is the suggestion how user should be notified
+    about the new message.
+    """
+    NO_NOTIFICATION = 0
+    HIGHLIGHT = 1
+    MAKE_VISIBLE = 2
+    RAISE_WINDOW = 3
+
+
 class Layer(object):
 class Layer(object):
     """!Layer is generaly usable layer object.
     """!Layer is generaly usable layer object.
 
 
@@ -108,24 +118,18 @@ class GrassInterface:
         """
         """
         raise NotImplementedError()
         raise NotImplementedError()
 
 
-    def WriteLog(self, text, wrap=None, switchPage=False, priority=1):
+    def WriteLog(self, text, wrap=None, notification=Notification.HIGHLIGHT):
         """!Writes log message.
         """!Writes log message.
-
-        @note It is not clear how the switchPage and priority should work.
-        @note Use priority rather than switchPage, switchPage will be removed.
         """
         """
         raise NotImplementedError()
         raise NotImplementedError()
 
 
-    def WriteCmdLog(self, line, pid=None, switchPage=True):
+    def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
         """!Writes message related to start or end of the command.
         """!Writes message related to start or end of the command.
         """
         """
         raise NotImplementedError()
         raise NotImplementedError()
 
 
     def WriteWarning(self, line):
     def WriteWarning(self, line):
         """!Writes warning message for the user.
         """!Writes warning message for the user.
-
-        Currently used also for important messages for user.
-        Overlaps with log message with high priority.
         """
         """
         raise NotImplementedError()
         raise NotImplementedError()
 
 
@@ -189,6 +193,10 @@ class StandaloneGrassInterface():
         # Signal emitted to request updating of map
         # Signal emitted to request updating of map
         self.updateMap = Signal('StandaloneGrassInterface.updateMap')
         self.updateMap = Signal('StandaloneGrassInterface.updateMap')
 
 
+        from core.gconsole import GConsole, \
+            EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, \
+            EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
+
         self._gconsole = GConsole()
         self._gconsole = GConsole()
         self._gconsole.Bind(EVT_CMD_PROGRESS, self._onCmdProgress)
         self._gconsole.Bind(EVT_CMD_PROGRESS, self._onCmdProgress)
         self._gconsole.Bind(EVT_CMD_OUTPUT, self._onCmdOutput)
         self._gconsole.Bind(EVT_CMD_OUTPUT, self._onCmdOutput)
@@ -219,20 +227,20 @@ class StandaloneGrassInterface():
         grass.percent(event.value, 100, 1)
         grass.percent(event.value, 100, 1)
         event.Skip()
         event.Skip()
 
 
-    def RunCmd(self, command, compReg=True, switchPage=False, skipInterface=False,
-               onDone=None, onPrepare=None, userData=None, priority=1):
-        self._gconsole.RunCmd(command=command, compReg=compReg, switchPage=switchPage,
+    def RunCmd(self, command, compReg=True, skipInterface=False,
+               onDone=None, onPrepare=None, userData=None, notification=Notification.MAKE_VISIBLE):
+        self._gconsole.RunCmd(command=command, compReg=compReg,
                               skipInterface=skipInterface, onDone=onDone,
                               skipInterface=skipInterface, onDone=onDone,
-                              onPrepare=onPrepare, userData=userData, priority=priority)
+                              onPrepare=onPrepare, userData=userData, notification=notification)
 
 
     def Help(self, entry):
     def Help(self, entry):
         self._gconsole.RunCmd(['g.manual', 'entry=%s' % entry])
         self._gconsole.RunCmd(['g.manual', 'entry=%s' % entry])
 
 
     def WriteLog(self, text, wrap=None,
     def WriteLog(self, text, wrap=None,
-                 switchPage=False, priority=1):
+                 notification=Notification.HIGHLIGHT):
         self._write(grass.message, text)
         self._write(grass.message, text)
 
 
-    def WriteCmdLog(self, line, pid=None, switchPage=True):
+    def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
         if pid:
         if pid:
             line = '(' + str(pid) + ') ' + line
             line = '(' + str(pid) + ') ' + line
         self._write(grass.message, line)
         self._write(grass.message, line)

+ 2 - 1
gui/wxpython/gcp/manager.py

@@ -48,6 +48,7 @@ from gui_core.dialogs  import GroupDialog
 from core.gcmd         import RunCommand, GMessage, GError, GWarning
 from core.gcmd         import RunCommand, GMessage, GError, GWarning
 from core.settings     import UserSettings
 from core.settings     import UserSettings
 from gcp.mapdisplay    import MapFrame
 from gcp.mapdisplay    import MapFrame
+from core.giface import Notification
 
 
 from location_wizard.wizard   import TitledPage as TitledPage
 from location_wizard.wizard   import TitledPage as TitledPage
 
 
@@ -1446,7 +1447,7 @@ class GCP(MapFrame, ColumnSorterMixin):
             for vect in vectlist:
             for vect in vectlist:
                 self.outname = str(vect.split('@')[0]) + self.extension
                 self.outname = str(vect.split('@')[0]) + self.extension
                 self._giface.WriteLog(text = _('Transforming <%s>...') % vect,
                 self._giface.WriteLog(text = _('Transforming <%s>...') % vect,
-                                             switchPage = True)
+                                      notification=Notification.MAKE_VISIBLE)
                 ret = msg = ''
                 ret = msg = ''
                 
                 
                 busy = wx.BusyInfo(message=_("Rectifying vector map <%s>, please wait...") % vect,
                 busy = wx.BusyInfo(message=_("Rectifying vector map <%s>, please wait...") % vect,

+ 13 - 14
gui/wxpython/gmodeler/frame.py

@@ -36,7 +36,7 @@ from core                 import globalvar
 from core.utils import _
 from core.utils import _
 from gui_core.widgets     import GNotebook
 from gui_core.widgets     import GNotebook
 from core.gconsole        import GConsole, \
 from core.gconsole        import GConsole, \
-    EVT_CMD_RUN, EVT_CMD_DONE, EVT_CMD_PREPARE, EVT_CMD_RUN, EVT_CMD_DONE
+    EVT_CMD_RUN, EVT_CMD_DONE, EVT_CMD_PREPARE
 from gui_core.goutput     import GConsoleWindow
 from gui_core.goutput     import GConsoleWindow
 from core.debug           import Debug
 from core.debug           import Debug
 from core.gcmd            import GMessage, GException, GWarning, GError, RunCommand
 from core.gcmd            import GMessage, GException, GWarning, GError, RunCommand
@@ -49,6 +49,7 @@ from gmodeler.menudata    import ModelerMenuData
 from gui_core.forms       import GUI
 from gui_core.forms       import GUI
 from gmodeler.preferences import PreferencesDialog, PropertiesDialog
 from gmodeler.preferences import PreferencesDialog, PropertiesDialog
 from gmodeler.toolbars    import ModelerToolbar
 from gmodeler.toolbars    import ModelerToolbar
+from core.giface import Notification
 
 
 from gmodeler.model       import *
 from gmodeler.model       import *
 from gmodeler.dialogs     import *
 from gmodeler.dialogs     import *
@@ -114,11 +115,9 @@ class ModelFrame(wx.Frame):
 
 
         # here events are binded twice
         # here events are binded twice
         self._gconsole.Bind(EVT_CMD_RUN,
         self._gconsole.Bind(EVT_CMD_RUN,
-                                lambda event:
-                                    self._switchPageHandler(event = event, priority = 2))
+            lambda event: self._switchPageHandler(event=event, notification=Notification.MAKE_VISIBLE))
         self._gconsole.Bind(EVT_CMD_DONE,
         self._gconsole.Bind(EVT_CMD_DONE,
-                                lambda event:
-                                    self._switchPageHandler(event = event, priority = 3))
+            lambda event: self._switchPageHandler(event=event, notification=Notification.RAISE_WINDOW))
         self.Bind(EVT_CMD_RUN, self.OnCmdRun)
         self.Bind(EVT_CMD_RUN, self.OnCmdRun)
         self.Bind(EVT_CMD_DONE, self.OnCmdDone)
         self.Bind(EVT_CMD_DONE, self.OnCmdDone)
         self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
         self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
@@ -705,17 +704,18 @@ class ModelFrame(wx.Frame):
         
         
         self.canvas.Refresh()
         self.canvas.Refresh()
 
 
-    def _switchPageHandler(self, event, priority):
-        self._switchPage(priority = priority)
+    def _switchPageHandler(self, event, notification):
+        self._switchPage(notification=notification)
         event.Skip()
         event.Skip()
 
 
-    def _switchPage(self, priority):
-        """!Manages @c 'output' notebook page according to event priority."""
-        if priority == 1:
+    def _switchPage(self, notification):
+        """!Manages @c 'output' notebook page according to event notification."""
+        if notification == Notification.HIGHLIGHT:
             self.notebook.HighlightPageByName('output')
             self.notebook.HighlightPageByName('output')
-        if priority >= 2:
+        if notification == Notification.MAKE_VISIBLE:
+            self.notebook.SetSelectionByName('output')
+        if notification == Notification.RAISE_WINDOW:
             self.notebook.SetSelectionByName('output')
             self.notebook.SetSelectionByName('output')
-        if priority >= 3:
             self.SetFocus()
             self.SetFocus()
             self.Raise()
             self.Raise()
 
 
@@ -1554,8 +1554,7 @@ class PythonPanel(wx.Panel):
             mode = stat.S_IMODE(os.lstat(self.filename)[stat.ST_MODE])
             mode = stat.S_IMODE(os.lstat(self.filename)[stat.ST_MODE])
             os.chmod(self.filename, mode | stat.S_IXUSR)
             os.chmod(self.filename, mode | stat.S_IXUSR)
         
         
-        self.parent._gconsole.RunCmd([fd.name], switchPage = True,
-                                     skipInterface = True, onDone = self.OnDone)
+        self.parent._gconsole.RunCmd([fd.name], skipInterface=True, onDone=self.OnDone)
         
         
         event.Skip()
         event.Skip()
 
 

+ 2 - 2
gui/wxpython/gui_core/dialogs.py

@@ -1801,7 +1801,7 @@ class GdalImportDialog(ImportDialog):
                 cmd.append('--overwrite')
                 cmd.append('--overwrite')
             
             
             # run in Layer Manager
             # run in Layer Manager
-            self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
+            self._giface.RunCmd(cmd, onDone=self.AddLayers)
         
         
         if popOGR:
         if popOGR:
             os.environ.pop('GRASS_VECTOR_OGR')
             os.environ.pop('GRASS_VECTOR_OGR')
@@ -1963,7 +1963,7 @@ class DxfImportDialog(ImportDialog):
                 cmd.append('--overwrite')
                 cmd.append('--overwrite')
             
             
             # run in Layer Manager
             # run in Layer Manager
-            self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
+            self._giface.RunCmd(cmd, onDone=self.AddLayers)
         
         
         self.Close()
         self.Close()
 
 

+ 11 - 9
gui/wxpython/gui_core/forms.py

@@ -98,6 +98,7 @@ from core             import utils
 from core.utils import _
 from core.utils import _
 from core.settings    import UserSettings
 from core.settings    import UserSettings
 from gui_core.widgets import FloatValidator, GNotebook, FormNotebook, FormListbook
 from gui_core.widgets import FloatValidator, GNotebook, FormNotebook, FormListbook
+from core.giface import Notification
 
 
 wxUpdateDialog, EVT_DIALOG_UPDATE = NewEvent()
 wxUpdateDialog, EVT_DIALOG_UPDATE = NewEvent()
 
 
@@ -1761,10 +1762,10 @@ class CmdPanel(wx.Panel):
             self.goutput = GConsoleWindow(parent = self.notebook, gconsole = self._gconsole, margin = False)
             self.goutput = GConsoleWindow(parent = self.notebook, gconsole = self._gconsole, margin = False)
             self._gconsole.Bind(EVT_CMD_RUN,
             self._gconsole.Bind(EVT_CMD_RUN,
                                 lambda event:
                                 lambda event:
-                                    self._switchPageHandler(event = event, priority = 2))
+                                    self._switchPageHandler(event=event, notification=Notification.MAKE_VISIBLE))
             self._gconsole.Bind(EVT_CMD_DONE,
             self._gconsole.Bind(EVT_CMD_DONE,
                                 lambda event:
                                 lambda event:
-                                    self._switchPageHandler(event = event, priority = 3))
+                                    self._switchPageHandler(event = event, notification=Notification.RAISE_WINDOW))
             self.outpage = self.notebook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
             self.outpage = self.notebook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
         else:
         else:
             self.goutput = None
             self.goutput = None
@@ -1999,17 +2000,18 @@ class CmdPanel(wx.Panel):
             # event is somehow propagated?
             # event is somehow propagated?
             event.StopPropagation()
             event.StopPropagation()
 
 
-    def _switchPageHandler(self, event, priority):
-        self._switchPage(priority = priority)
+    def _switchPageHandler(self, event, notification):
+        self._switchPage(notification=notification)
         event.Skip()
         event.Skip()
 
 
-    def _switchPage(self, priority):
-        """!Manages @c 'output' notebook page according to event priority."""
-        if priority == 1:
+    def _switchPage(self, notification):
+        """!Manages @c 'output' notebook page according to event notification."""
+        if notification == Notification.HIGHLIGHT:
             self.notebook.HighlightPageByName('output')
             self.notebook.HighlightPageByName('output')
-        if priority >= 2:
+        if notification == Notification.MAKE_VISIBLE:
+            self.notebook.SetSelectionByName('output')
+        if notification == Notification.RAISE_WINDOW:
             self.notebook.SetSelectionByName('output')
             self.notebook.SetSelectionByName('output')
-        if priority >= 3:
             self.SetFocus()
             self.SetFocus()
             self.Raise()
             self.Raise()
 
 

+ 20 - 29
gui/wxpython/gui_core/goutput.py

@@ -36,7 +36,7 @@ from grass.pydispatch.signal import Signal
 from core.gcmd       import GError, EncodeString
 from core.gcmd       import GError, EncodeString
 from core.gconsole   import GConsole, \
 from core.gconsole   import GConsole, \
     EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, EVT_CMD_RUN, EVT_CMD_DONE, \
     EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, EVT_CMD_RUN, EVT_CMD_DONE, \
-    EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
+    EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR, Notification
 from gui_core.prompt import GPromptSTC
 from gui_core.prompt import GPromptSTC
 from core.settings   import UserSettings
 from core.settings   import UserSettings
 from core.utils import _
 from core.utils import _
@@ -48,11 +48,6 @@ GC_SEARCH = 1
 GC_PROMPT = 2
 GC_PROMPT = 2
 
 
 
 
-# occurs when a content of console output window was changed
-# some similar event exists in GConsole this will be not neccessary
-gGcContentChanged, EVT_GC_CONTENT_CHANGED = NewEvent()
-
-
 class GConsoleWindow(wx.SplitterWindow):
 class GConsoleWindow(wx.SplitterWindow):
     """!Create and manage output console for commands run by GUI.
     """!Create and manage output console for commands run by GUI.
     """
     """
@@ -86,6 +81,10 @@ class GConsoleWindow(wx.SplitterWindow):
 
 
         # signal which requests showing of a notification
         # signal which requests showing of a notification
         self.showNotification = Signal("GConsoleWindow.showNotification")
         self.showNotification = Signal("GConsoleWindow.showNotification")
+        # signal emitted when text appears in the console
+        # parameter 'notification' suggests form of notification (according to
+        # core.giface.Notification)
+        self.contentChanged = Signal("GConsoleWindow.contentChanged")
 
 
         # progress bar
         # progress bar
         self.progressbar = wx.Gauge(parent = self.panelProgress, id = wx.ID_ANY,
         self.progressbar = wx.Gauge(parent = self.panelProgress, id = wx.ID_ANY,
@@ -99,13 +98,12 @@ class GConsoleWindow(wx.SplitterWindow):
                             lambda event:
                             lambda event:
                                 self.WriteLog(text = event.text,
                                 self.WriteLog(text = event.text,
                                               wrap = event.wrap,
                                               wrap = event.wrap,
-                                              switchPage = event.switchPage,
-                                              priority = event.priority))
+                                              notification=event.notification))
         self._gconsole.Bind(EVT_WRITE_CMD_LOG,
         self._gconsole.Bind(EVT_WRITE_CMD_LOG,
                             lambda event:
                             lambda event:
                                 self.WriteCmdLog(line = event.line,
                                 self.WriteCmdLog(line = event.line,
                                                  pid = event.pid,
                                                  pid = event.pid,
-                                                 switchPage = event.switchPage))
+                                                 notification=event.notification))
         self._gconsole.Bind(EVT_WRITE_WARNING,
         self._gconsole.Bind(EVT_WRITE_WARNING,
                             lambda event:
                             lambda event:
                                 self.WriteWarning(line = event.line))
                                 self.WriteWarning(line = event.line))
@@ -116,7 +114,6 @@ class GConsoleWindow(wx.SplitterWindow):
         # text control for command output
         # text control for command output
         self.cmdOutput = GStc(parent = self.panelOutput, id = wx.ID_ANY, margin = margin,
         self.cmdOutput = GStc(parent = self.panelOutput, id = wx.ID_ANY, margin = margin,
                                wrap = None)
                                wrap = None)
-        self.cmdOutput.Bind(stc.EVT_STC_CHANGE, self.OnStcChanged)
 
 
         # search & command prompt
         # search & command prompt
         # move to the if below
         # move to the if below
@@ -305,19 +302,15 @@ class GConsoleWindow(wx.SplitterWindow):
 
 
         return self.panelOutput
         return self.panelOutput
 
 
-    def WriteLog(self, text, style = None, wrap = None,
-                 switchPage = False, priority = 1):
+    def WriteLog(self, text, style=None, wrap=None,
+                 notification=Notification.HIGHLIGHT):
         """!Generic method for writing log message in 
         """!Generic method for writing log message in 
         given style
         given style
 
 
         @param line text line
         @param line text line
         @param style text style (see GStc)
         @param style text style (see GStc)
         @param stdout write to stdout or stderr
         @param stdout write to stdout or stderr
-        @param switchPage for backward compatibility
-        (replace by priority: False=1, True=2)
-        @param priority priority of this message
-        (0=no priority, 1=normal, 2=medium, 3=high)
-        also not clear how deal with this
+        @param notification form of notification
         """
         """
 
 
         self.cmdOutput.SetStyle()
         self.cmdOutput.SetStyle()
@@ -348,8 +341,10 @@ class GConsoleWindow(wx.SplitterWindow):
             self.cmdOutput.SetStyling(p2 - p1, style)
             self.cmdOutput.SetStyling(p2 - p1, style)
         
         
         self.cmdOutput.EnsureCaretVisible()
         self.cmdOutput.EnsureCaretVisible()
+
+        self.contentChanged.emit(notification=notification)
         
         
-    def WriteCmdLog(self, line, pid = None, switchPage = True):
+    def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
         """!Write message in selected style
         """!Write message in selected style
         
         
         @param line message to be printed
         @param line message to be printed
@@ -358,15 +353,15 @@ class GConsoleWindow(wx.SplitterWindow):
         """
         """
         if pid:
         if pid:
             line = '(' + str(pid) + ') ' + line
             line = '(' + str(pid) + ') ' + line
-        self.WriteLog(line, style = self.cmdOutput.StyleCommand, switchPage = switchPage)
+        self.WriteLog(line, style = self.cmdOutput.StyleCommand, notification=notification)
 
 
     def WriteWarning(self, line):
     def WriteWarning(self, line):
         """!Write message in warning style"""
         """!Write message in warning style"""
-        self.WriteLog(line, style = self.cmdOutput.StyleWarning, switchPage = True)
+        self.WriteLog(line, style = self.cmdOutput.StyleWarning, notification=Notification.MAKE_VISIBLE)
 
 
     def WriteError(self, line):
     def WriteError(self, line):
         """!Write message in error style"""
         """!Write message in error style"""
-        self.WriteLog(line, style = self.cmdOutput.StyleError, switchPage = True)
+        self.WriteLog(line, style = self.cmdOutput.StyleError, notification=Notification.MAKE_VISIBLE)
 
 
     def OnOutputClear(self, event):
     def OnOutputClear(self, event):
         """!Clear content of output window"""
         """!Clear content of output window"""
@@ -427,16 +422,16 @@ class GConsoleWindow(wx.SplitterWindow):
 
 
     def OnCmdOutput(self, event):
     def OnCmdOutput(self, event):
         """!Print command output
         """!Print command output
-
-        Posts event EVT_OUTPUT_TEXT with priority attribute set to 1.
         """
         """
         message = event.text
         message = event.text
         type  = event.type
         type  = event.type
 
 
         self.cmdOutput.AddStyledMessage(message, type)
         self.cmdOutput.AddStyledMessage(message, type)
 
 
-        # documenting old behavior/implementation:
-        # add elipses if not active
+        if event.type in ('warning', 'error'):
+            self.contentChanged.emit(notification=Notification.MAKE_VISIBLE)
+        else:
+            self.contentChanged.emit(notification=Notification.HIGHLIGHT)
 
 
     def OnCmdProgress(self, event):
     def OnCmdProgress(self, event):
         """!Update progress message info"""
         """!Update progress message info"""
@@ -505,10 +500,6 @@ class GConsoleWindow(wx.SplitterWindow):
     def _hideProgress(self):
     def _hideProgress(self):
         self.outputSizer.Hide(self.panelProgress)
         self.outputSizer.Hide(self.panelProgress)
         self.outputSizer.Layout()
         self.outputSizer.Layout()
-        
-    def OnStcChanged(self, event):
-        newEvent = gGcContentChanged()
-        wx.PostEvent(self, newEvent)
 
 
     def ResetFocus(self):
     def ResetFocus(self):
         """!Reset focus"""
         """!Reset focus"""

+ 16 - 37
gui/wxpython/lmgr/frame.py

@@ -53,10 +53,9 @@ from gui_core.widgets      import GNotebook
 from modules.mcalc_builder import MapCalcFrame
 from modules.mcalc_builder import MapCalcFrame
 from dbmgr.manager         import AttributeManager
 from dbmgr.manager         import AttributeManager
 from core.workspace        import ProcessWorkspaceFile, ProcessGrcFile, WriteWorkspaceFile
 from core.workspace        import ProcessWorkspaceFile, ProcessGrcFile, WriteWorkspaceFile
-from core.gconsole         import GConsole, \
-    EVT_CMD_OUTPUT, EVT_IGNORED_CMD_RUN, EVT_IMPORTANT_CMD_RUN, \
-    EVT_WRITE_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
-from gui_core.goutput      import GConsoleWindow, EVT_GC_CONTENT_CHANGED, GC_SEARCH, GC_PROMPT
+from core.gconsole         import GConsole, EVT_IGNORED_CMD_RUN
+from core.giface           import Notification
+from gui_core.goutput      import GConsoleWindow, GC_SEARCH, GC_PROMPT
 from gui_core.dialogs      import GdalOutputDialog, DxfImportDialog, GdalImportDialog, MapLayersDialog
 from gui_core.dialogs      import GdalOutputDialog, DxfImportDialog, GdalImportDialog, MapLayersDialog
 from gui_core.dialogs      import LocationDialog, MapsetDialog, CreateNewVector, GroupDialog
 from gui_core.dialogs      import LocationDialog, MapsetDialog, CreateNewVector, GroupDialog
 from modules.colorrules    import RasterColorTable, VectorColorTable
 from modules.colorrules    import RasterColorTable, VectorColorTable
@@ -292,33 +291,12 @@ class GMFrame(wx.Frame):
         self.goutput.showNotification.connect(lambda message: self.SetStatusText(message))
         self.goutput.showNotification.connect(lambda message: self.SetStatusText(message))
 
 
         self._gconsole.mapCreated.connect(self.OnMapCreated)
         self._gconsole.mapCreated.connect(self.OnMapCreated)
+        self.goutput.contentChanged.connect(
+            lambda notification: self._switchPage(notification))
 
 
-        # EVT_CMD_OUTPUT and EVT_GC_CONTENT_CHANGED are similar but should be distinct
-        # (logging/messages may be splited from GConsole commad running interface)
-        # thus, leaving this bind here
-        self._gconsole.Bind(EVT_CMD_OUTPUT,
-                                lambda event:
-                                    self._switchPageHandler(event = event, priority = 1))
-        self._gconsole.Bind(EVT_IMPORTANT_CMD_RUN,
-                            lambda event:
-                                self._switchPageHandler(event = event, priority = 2))
         self._gconsole.Bind(EVT_IGNORED_CMD_RUN,
         self._gconsole.Bind(EVT_IGNORED_CMD_RUN,
                             lambda event: self.RunSpecialCmd(event.cmd))
                             lambda event: self.RunSpecialCmd(event.cmd))
-        # if you are chnaging GConsoleWindow to GConsole and
-        # EVT_GC_CONTENT_CHANGED to somthing like EVT_LOG_OUTPUT
-        # you are doing right
-        self.goutput.Bind(EVT_GC_CONTENT_CHANGED,
-                          lambda event:
-                              self._switchPageHandler(event = event, priority = 1))
-        self._gconsole.Bind(EVT_WRITE_LOG,
-                            lambda event:
-                                self._switchPageHandler(event = event, priority = event.priority))
-        self._gconsole.Bind(EVT_WRITE_WARNING,
-                            lambda event:
-                                self._switchPageHandler(event = event, priority = 2))
-        self._gconsole.Bind(EVT_WRITE_ERROR,
-                            lambda event:
-                                self._switchPageHandler(event = event, priority = 2))
+
         self._setCopyingOfSelectedText()
         self._setCopyingOfSelectedText()
         
         
         # create 'search module' notebook page
         # create 'search module' notebook page
@@ -596,17 +574,18 @@ class GMFrame(wx.Frame):
 
 
         event.Skip()
         event.Skip()
 
 
-    def _switchPageHandler(self, event, priority):
-        self._switchPage(priority = priority)
+    def _switchPageHandler(self, event, notification):
+        self._switchPage(notification=notification)
         event.Skip()
         event.Skip()
 
 
-    def _switchPage(self, priority):
-        """!Manages @c 'output' notebook page according to event priority."""
-        if priority == 1:
+    def _switchPage(self, notification):
+        """!Manages @c 'output' notebook page according to event notification."""
+        if notification == Notification.HIGHLIGHT:
             self.notebook.HighlightPageByName('output')
             self.notebook.HighlightPageByName('output')
-        if priority >= 2:
+        if notification == Notification.MAKE_VISIBLE:
+            self.notebook.SetSelectionByName('output')
+        if notification == Notification.RAISE_WINDOW:
             self.notebook.SetSelectionByName('output')
             self.notebook.SetSelectionByName('output')
-        if priority >= 3:
             self.SetFocus()
             self.SetFocus()
             self.Raise()
             self.Raise()
 
 
@@ -868,7 +847,7 @@ class GMFrame(wx.Frame):
                 SetAddOnPath(os.pathsep.join(addonPath), key = 'PATH')
                 SetAddOnPath(os.pathsep.join(addonPath), key = 'PATH')
         
         
         self._gconsole.WriteCmdLog(_("Launching script '%s'...") % filename)
         self._gconsole.WriteCmdLog(_("Launching script '%s'...") % filename)
-        self._gconsole.RunCmd([filename], switchPage = True)
+        self._gconsole.RunCmd([filename])
         
         
     def OnChangeLocation(self, event):
     def OnChangeLocation(self, event):
         """Change current location"""
         """Change current location"""
@@ -999,7 +978,7 @@ class GMFrame(wx.Frame):
                                                platform.python_version(),
                                                platform.python_version(),
                                                wx.__version__,
                                                wx.__version__,
                                                _("Platform"), platform.platform().decode('utf8', 'replace'), osgeo4w),
                                                _("Platform"), platform.platform().decode('utf8', 'replace'), osgeo4w),
-                                priority = 2)
+                                notification=Notification.MAKE_VISIBLE)
         self._gconsole.WriteCmdLog(' ')
         self._gconsole.WriteCmdLog(' ')
     
     
     def OnAboutGRASS(self, event):
     def OnAboutGRASS(self, event):

+ 7 - 6
gui/wxpython/lmgr/giface.py

@@ -16,6 +16,7 @@ This program is free software under the GNU General Public License
 """
 """
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal
+from core.giface import Notification
 
 
 
 
 class Layer(object):
 class Layer(object):
@@ -145,15 +146,15 @@ class LayerManagerGrassInterface(object):
 
 
     def Help(self, entry):
     def Help(self, entry):
         cmdlist = ['g.manual', 'entry=%s' % entry]
         cmdlist = ['g.manual', 'entry=%s' % entry]
-        self.RunCmd(cmdlist, compReg = False, switchPage = False)
+        self.RunCmd(cmdlist, compReg = False, notification=Notification.NO_NOTIFICATION)
 
 
     def WriteLog(self, text, wrap = None,
     def WriteLog(self, text, wrap = None,
-                 switchPage = False, priority = 1):
-        self.lmgr._gconsole.WriteLog(text = text, wrap = wrap, switchPage = switchPage,
-                                   priority = priority)
+                 notification=Notification.HIGHLIGHT):
+        self.lmgr._gconsole.WriteLog(text=text, wrap=wrap, 
+                                     notification=notification)
 
 
-    def WriteCmdLog(self, line, pid = None, switchPage = True):
-        self.lmgr._gconsole.WriteCmdLog(line = line, pid = pid, switchPage = switchPage)
+    def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
+        self.lmgr._gconsole.WriteCmdLog(line=line, pid=pid, notification=notification)
 
 
     def WriteWarning(self, line):
     def WriteWarning(self, line):
         self.lmgr._gconsole.WriteWarning(line = line)
         self.lmgr._gconsole.WriteWarning(line = line)

+ 5 - 5
gui/wxpython/lmgr/layertree.py

@@ -606,7 +606,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         mapLayer = self.GetLayerInfo(self.layer_selected, key = 'maplayer')
         mapLayer = self.GetLayerInfo(self.layer_selected, key = 'maplayer')
         cmd = ['v.build',
         cmd = ['v.build',
                'map=%s' % mapLayer.GetName()]
                'map=%s' % mapLayer.GetName()]
-        self._giface.RunCmd(cmd, switchPage = True)
+        self._giface.RunCmd(cmd)
 
 
     def OnSqlQuery(self, event):
     def OnSqlQuery(self, event):
         """!Show SQL query window for PostGIS layers
         """!Show SQL query window for PostGIS layers
@@ -631,7 +631,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
         cmd.append('map=%s' % mapLayer.GetName())
         cmd.append('map=%s' % mapLayer.GetName())
 
 
         # print output to command log area
         # print output to command log area
-        self._giface.RunCmd(cmd, switchPage = True)
+        self._giface.RunCmd(cmd)
 
 
     def OnSetCompRegFromRaster(self, event):
     def OnSetCompRegFromRaster(self, event):
         """!Set computational region from selected raster map (ignore NULLs)"""
         """!Set computational region from selected raster map (ignore NULLs)"""
@@ -814,10 +814,10 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                 raster2d.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
                 raster2d.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
         
         
         if raster2d:
         if raster2d:
-            self._giface.RunCmd(['r.univar', 'map=%s' % ','.join(raster2d)], switchPage=True)
+            self._giface.RunCmd(['r.univar', 'map=%s' % ','.join(raster2d)])
         
         
         if raster3d:
         if raster3d:
-            self._giface.RunCmd(['r3.univar', 'map=%s' % ','.join(raster3d)], switchPage=True)
+            self._giface.RunCmd(['r3.univar', 'map=%s' % ','.join(raster3d)])
 
 
     def OnReportStats(self, event):
     def OnReportStats(self, event):
         """!Print 2D statistics"""
         """!Print 2D statistics"""
@@ -828,7 +828,7 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                 rasters.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
                 rasters.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
         
         
         if rasters:
         if rasters:
-            self._giface.RunCmd(['r.report', 'map=%s' % ','.join(rasters), 'units=h,c,p'], switchPage=True)
+            self._giface.RunCmd(['r.report', 'map=%s' % ','.join(rasters), 'units=h,c,p'])
         
         
     def OnStartEditing(self, event):
     def OnStartEditing(self, event):
         """!Start editing vector map layer requested by the user
         """!Start editing vector map layer requested by the user

+ 6 - 4
gui/wxpython/mapdisp/frame.py

@@ -58,6 +58,7 @@ from wxplot.profile     import ProfileFrame
 from wxplot.scatter     import ScatterFrame
 from wxplot.scatter     import ScatterFrame
 from mapwin.analysis import ProfileController, MeasureDistanceController
 from mapwin.analysis import ProfileController, MeasureDistanceController
 from gui_core.forms import GUI
 from gui_core.forms import GUI
+from core.giface import Notification
 
 
 from mapdisp import statusbar as sb
 from mapdisp import statusbar as sb
 
 
@@ -336,7 +337,7 @@ class MapFrame(SingleMapFrame):
         # erase map window
         # erase map window
         self.MapWindow.EraseMap()
         self.MapWindow.EraseMap()
         
         
-        self._giface.WriteCmdLog(_("Starting 3D view mode..."))
+        self._giface.WriteCmdLog(_("Starting 3D view mode..."), notification=Notification.HIGHLIGHT)
         self.SetStatusText(_("Please wait, loading data..."), 0)
         self.SetStatusText(_("Please wait, loading data..."), 0)
         
         
         # create GL window
         # create GL window
@@ -410,7 +411,9 @@ class MapFrame(SingleMapFrame):
                                                        key = 'statusbarMode',
                                                        key = 'statusbarMode',
                                                        subkey = 'selection'))
                                                        subkey = 'selection'))
         self.SetStatusText(_("Please wait, unloading data..."), 0)
         self.SetStatusText(_("Please wait, unloading data..."), 0)
-        self._giface.WriteCmdLog(_("Switching back to 2D view mode..."))
+        # unloading messages from library cause highlight anyway
+        self._giface.WriteCmdLog(_("Switching back to 2D view mode..."),
+                                 notification=Notification.NO_NOTIFICATION)
         if self.MapWindow3D:
         if self.MapWindow3D:
             self.MapWindow3D.OnClose(event = None)
             self.MapWindow3D.OnClose(event = None)
         # switch from MapWindowGL to MapWindow
         # switch from MapWindowGL to MapWindow
@@ -735,9 +738,8 @@ class MapFrame(SingleMapFrame):
 
 
     def _onRedirectQueryOutput(self, output, style='log'):
     def _onRedirectQueryOutput(self, output, style='log'):
         """!Writes query output into console"""
         """!Writes query output into console"""
-        # TODO: fix switching tab
         if style == 'log':
         if style == 'log':
-            self._giface.WriteLog(output)
+            self._giface.WriteLog(output, notification=Notification.MAKE_VISIBLE)
         elif style == 'cmd':
         elif style == 'cmd':
             self._giface.WriteCmdLog(output)
             self._giface.WriteCmdLog(output)
 
 

+ 2 - 1
gui/wxpython/mapwin/analysis.py

@@ -23,6 +23,7 @@ import wx
 
 
 from core.utils import _
 from core.utils import _
 import core.units as units
 import core.units as units
+from core.giface import Notification
 
 
 from grass.pydispatch.signal import Signal
 from grass.pydispatch.signal import Signal
 
 
@@ -279,6 +280,6 @@ class MeasureDistanceController(AnalysisControllerBase):
                    _('total distance'), strtotdist, tdunits,
                    _('total distance'), strtotdist, tdunits,
                    '-' * 60)
                    '-' * 60)
 
 
-        self._giface.WriteLog(mstring, priority=2)
+        self._giface.WriteLog(mstring, notification=Notification.MAKE_VISIBLE)
 
 
         return dist
         return dist

+ 2 - 1
gui/wxpython/nviz/mapwindow.py

@@ -44,6 +44,7 @@ from nviz.animation     import Animation
 from nviz               import wxnviz
 from nviz               import wxnviz
 from core.globalvar     import CheckWxVersion
 from core.globalvar     import CheckWxVersion
 from core.utils         import str2rgb, _
 from core.utils         import str2rgb, _
+from core.giface import Notification
 
 
 wxUpdateProperties, EVT_UPDATE_PROP  = NewEvent()
 wxUpdateProperties, EVT_UPDATE_PROP  = NewEvent()
 wxUpdateView,       EVT_UPDATE_VIEW  = NewEvent()
 wxUpdateView,       EVT_UPDATE_VIEW  = NewEvent()
@@ -2550,7 +2551,7 @@ class GLWindow(MapWindowBase, glcanvas.GLCanvas):
     
     
     def OnNvizCmd(self):
     def OnNvizCmd(self):
         """!Generate and write command to command output"""
         """!Generate and write command to command output"""
-        self.log.WriteLog(self.NvizCmdCommand(), priority = 3)
+        self.log.WriteLog(self.NvizCmdCommand(), notification=Notification.RAISE_WINDOW)
         
         
     def SaveToFile(self, FileName, FileType, width, height):
     def SaveToFile(self, FileName, FileType, width, height):
         """!This draws the DC to a buffer that can be saved to a file.
         """!This draws the DC to a buffer that can be saved to a file.

+ 13 - 10
gui/wxpython/scripts/vkrige.py

@@ -41,6 +41,7 @@ from core import gconsole
 from gui_core import goutput
 from gui_core import goutput
 from core.settings import UserSettings
 from core.settings import UserSettings
 from gui_core.widgets import GNotebook
 from gui_core.widgets import GNotebook
+from core.giface import Notification
 #import help
 #import help
 
 
 import wx
 import wx
@@ -105,10 +106,10 @@ class KrigingPanel(wx.Panel):
         self.outpage = self.RPackagesBook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
         self.outpage = self.RPackagesBook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
         self._gconsole.Bind(gconsole.EVT_CMD_RUN,
         self._gconsole.Bind(gconsole.EVT_CMD_RUN,
                             lambda event:
                             lambda event:
-                                self._switchPageHandler(event = event, priority = 2))
+                                self._switchPageHandler(event=event, notification=Notification.MAKE_VISIBLE))
         self._gconsole.Bind(gconsole.EVT_CMD_DONE,
         self._gconsole.Bind(gconsole.EVT_CMD_DONE,
                             lambda event:
                             lambda event:
-                                self._switchPageHandler(event = event, priority = 3))
+                                self._switchPageHandler(event=event, notification=Notification.RAISE_WINDOW))
         self.RPackagesBook.SetSelection(0)
         self.RPackagesBook.SetSelection(0)
         KrigingSizer.Add(self.RPackagesBook, proportion = 1, flag = wx.EXPAND)
         KrigingSizer.Add(self.RPackagesBook, proportion = 1, flag = wx.EXPAND)
         
         
@@ -250,25 +251,27 @@ class KrigingPanel(wx.Panel):
         # give it to the output console
         # give it to the output console
         #@FIXME: it runs the command as a NEW instance. Reimports data, recalculates variogram fit..
         #@FIXME: it runs the command as a NEW instance. Reimports data, recalculates variogram fit..
         #otherwise I can use Controller() and mimic RunCmd behaviour.
         #otherwise I can use Controller() and mimic RunCmd behaviour.
-        self._gconsole.RunCmd(command, switchPage = True)
+        self._gconsole.RunCmd(command)
     
     
     def OnVarianceCBChecked(self, event):
     def OnVarianceCBChecked(self, event):
         self.OutputVarianceMapName.Enable(event.IsChecked())
         self.OutputVarianceMapName.Enable(event.IsChecked())
 
 
-    def _switchPageHandler(self, event, priority):
-        self._switchPage(priority = priority)
+    def _switchPageHandler(self, event, notification):
+        self._switchPage(notification=notification)
         event.Skip()
         event.Skip()
 
 
-    def _switchPage(self, priority):
-        """!Manages @c 'output' notebook page according to priority."""
-        if priority == 1:
+    def _switchPage(self, notification):
+        """!Manages @c 'output' notebook page according to event notification."""
+        if notification == Notification.HIGHLIGHT:
             self.RPackagesBook.HighlightPageByName('output')
             self.RPackagesBook.HighlightPageByName('output')
-        if priority >= 2:
+        if notification == Notification.MAKE_VISIBLE:
+            self.RPackagesBook.SetSelectionByName('output')
+        if notification == Notification.RAISE_WINDOW:
             self.RPackagesBook.SetSelectionByName('output')
             self.RPackagesBook.SetSelectionByName('output')
-        if priority >= 3:
             self.SetFocus()
             self.SetFocus()
             self.Raise()
             self.Raise()
 
 
+
 class KrigingModule(wx.Frame):
 class KrigingModule(wx.Frame):
     """ Kriging module for GRASS GIS. Depends on R and its packages gstat and geoR. """
     """ Kriging module for GRASS GIS. Depends on R and its packages gstat and geoR. """
     def __init__(self, parent, Rinstance, controller, *args, **kwargs):
     def __init__(self, parent, Rinstance, controller, *args, **kwargs):