[GRASS-SVN] r58086 - in grass/trunk/gui/wxpython: core gcp gmodeler gui_core lmgr mapdisp mapwin nviz scripts
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 21 19:12:20 PDT 2013
Author: annakrat
Date: 2013-10-21 19:12:20 -0700 (Mon, 21 Oct 2013)
New Revision: 58086
Modified:
grass/trunk/gui/wxpython/core/gconsole.py
grass/trunk/gui/wxpython/core/giface.py
grass/trunk/gui/wxpython/gcp/manager.py
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gui_core/dialogs.py
grass/trunk/gui/wxpython/gui_core/forms.py
grass/trunk/gui/wxpython/gui_core/goutput.py
grass/trunk/gui/wxpython/lmgr/frame.py
grass/trunk/gui/wxpython/lmgr/giface.py
grass/trunk/gui/wxpython/lmgr/layertree.py
grass/trunk/gui/wxpython/mapdisp/frame.py
grass/trunk/gui/wxpython/mapwin/analysis.py
grass/trunk/gui/wxpython/nviz/mapwindow.py
grass/trunk/gui/wxpython/scripts/vkrige.py
Log:
wxGUI: clean up message handling related to GConsole (co-author: wenzeslaus)
Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/core/gconsole.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -43,6 +43,7 @@
from gui_core.forms import GUI
from core.debug import Debug
from core.settings import UserSettings
+from core.giface import Notification
wxCmdOutput, EVT_CMD_OUTPUT = NewEvent()
@@ -115,7 +116,7 @@
os.environ['GRASS_MESSAGE_FORMAT'] = 'gui'
while True:
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:
vars()[key] = kwds[key]
del kwds[key]
@@ -139,7 +140,8 @@
# run command
event = wxCmdRun(cmd=args[0],
- pid=requestId)
+ pid=requestId,
+ notification=vars()['notification'])
wx.PostEvent(self.receiver, event)
@@ -199,7 +201,8 @@
time=requestTime,
pid=requestId,
onDone=vars()['onDone'],
- userData=vars()['userData'])
+ userData=vars()['userData'],
+ notification=vars()['notification'])
# send event
wx.PostEvent(self.receiver, event)
@@ -333,14 +336,7 @@
# Attribute cmd contains command (as a list).
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):
"""!
"""
@@ -395,29 +391,26 @@
sys.stderr = sys.__stderr__
def WriteLog(self, text, style=None, wrap=None,
- switchPage=False, priority=1):
+ notification=Notification.HIGHLIGHT):
"""!Generic method for writing log message in
given style
@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,
- switchPage=switchPage, priority=priority)
+ notification=notification)
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
@param line message to be printed
@param pid process pid or None
- @param switchPage True to switch page
+ @param notification form of notification
"""
event = gWriteCmdLog(line=line, pid=pid,
- switchPage=switchPage)
+ notification=notification)
wx.PostEvent(self, event)
def WriteWarning(self, line):
@@ -430,8 +423,8 @@
event = gWriteError(line=line)
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).
@todo Document the other event.
@@ -443,13 +436,9 @@
(according to ignoredCmdPattern) is run.
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 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
parser when command has no arguments given
@param onDone function to be called when command is finished
@@ -527,13 +516,6 @@
print >> sys.stderr, e
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)
# for all non-display commands.
if compReg:
@@ -547,7 +529,8 @@
stderr=self.cmdStdErr,
onDone=onDone, onPrepare=onPrepare,
userData=userData,
- env=os.environ.copy())
+ env=os.environ.copy(),
+ notification=notification)
self.cmdOutputTimer.Start(50)
# deactivate computational region and return to display settings
@@ -572,7 +555,8 @@
stdout=self.cmdStdOut,
stderr=self.cmdStdErr,
onDone=onDone, onPrepare=onPrepare,
- userData=userData)
+ userData=userData,
+ notification=notification)
self.cmdOutputTimer.Start(50)
def GetLog(self, err=False):
@@ -598,7 +582,8 @@
def OnCmdRun(self, event):
"""!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()
def OnCmdDone(self, event):
@@ -628,7 +613,8 @@
else:
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:
event.onDone(cmd=event.cmd, returncode=event.returncode)
Modified: grass/trunk/gui/wxpython/core/giface.py
===================================================================
--- grass/trunk/gui/wxpython/core/giface.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/core/giface.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -16,9 +16,6 @@
"""
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 _
import grass.script as grass
@@ -29,6 +26,19 @@
#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):
"""!Layer is generaly usable layer object.
@@ -108,24 +118,18 @@
"""
raise NotImplementedError()
- def WriteLog(self, text, wrap=None, switchPage=False, priority=1):
+ def WriteLog(self, text, wrap=None, notification=Notification.HIGHLIGHT):
"""!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()
- 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.
"""
raise NotImplementedError()
def WriteWarning(self, line):
"""!Writes warning message for the user.
-
- Currently used also for important messages for user.
- Overlaps with log message with high priority.
"""
raise NotImplementedError()
@@ -189,6 +193,10 @@
# Signal emitted to request updating of map
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.Bind(EVT_CMD_PROGRESS, self._onCmdProgress)
self._gconsole.Bind(EVT_CMD_OUTPUT, self._onCmdOutput)
@@ -219,20 +227,20 @@
grass.percent(event.value, 100, 1)
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,
- onPrepare=onPrepare, userData=userData, priority=priority)
+ onPrepare=onPrepare, userData=userData, notification=notification)
def Help(self, entry):
self._gconsole.RunCmd(['g.manual', 'entry=%s' % entry])
def WriteLog(self, text, wrap=None,
- switchPage=False, priority=1):
+ notification=Notification.HIGHLIGHT):
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:
line = '(' + str(pid) + ') ' + line
self._write(grass.message, line)
Modified: grass/trunk/gui/wxpython/gcp/manager.py
===================================================================
--- grass/trunk/gui/wxpython/gcp/manager.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/gcp/manager.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -48,6 +48,7 @@
from core.gcmd import RunCommand, GMessage, GError, GWarning
from core.settings import UserSettings
from gcp.mapdisplay import MapFrame
+from core.giface import Notification
from location_wizard.wizard import TitledPage as TitledPage
@@ -1446,7 +1447,7 @@
for vect in vectlist:
self.outname = str(vect.split('@')[0]) + self.extension
self._giface.WriteLog(text = _('Transforming <%s>...') % vect,
- switchPage = True)
+ notification=Notification.MAKE_VISIBLE)
ret = msg = ''
busy = wx.BusyInfo(message=_("Rectifying vector map <%s>, please wait...") % vect,
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -36,7 +36,7 @@
from core.utils import _
from gui_core.widgets import GNotebook
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 core.debug import Debug
from core.gcmd import GMessage, GException, GWarning, GError, RunCommand
@@ -49,6 +49,7 @@
from gui_core.forms import GUI
from gmodeler.preferences import PreferencesDialog, PropertiesDialog
from gmodeler.toolbars import ModelerToolbar
+from core.giface import Notification
from gmodeler.model import *
from gmodeler.dialogs import *
@@ -114,11 +115,9 @@
# here events are binded twice
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,
- 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_DONE, self.OnCmdDone)
self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
@@ -705,17 +704,18 @@
self.canvas.Refresh()
- def _switchPageHandler(self, event, priority):
- self._switchPage(priority = priority)
+ def _switchPageHandler(self, event, notification):
+ self._switchPage(notification=notification)
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')
- if priority >= 2:
+ if notification == Notification.MAKE_VISIBLE:
self.notebook.SetSelectionByName('output')
- if priority >= 3:
+ if notification == Notification.RAISE_WINDOW:
+ self.notebook.SetSelectionByName('output')
self.SetFocus()
self.Raise()
@@ -1554,8 +1554,7 @@
mode = stat.S_IMODE(os.lstat(self.filename)[stat.ST_MODE])
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()
Modified: grass/trunk/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/gui_core/dialogs.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -1801,7 +1801,7 @@
cmd.append('--overwrite')
# run in Layer Manager
- self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
+ self._giface.RunCmd(cmd, onDone=self.AddLayers)
if popOGR:
os.environ.pop('GRASS_VECTOR_OGR')
@@ -1963,7 +1963,7 @@
cmd.append('--overwrite')
# run in Layer Manager
- self._giface.RunCmd(cmd, switchPage = True, onDone = self.AddLayers)
+ self._giface.RunCmd(cmd, onDone=self.AddLayers)
self.Close()
Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/gui_core/forms.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -98,6 +98,7 @@
from core.utils import _
from core.settings import UserSettings
from gui_core.widgets import FloatValidator, GNotebook, FormNotebook, FormListbook
+from core.giface import Notification
wxUpdateDialog, EVT_DIALOG_UPDATE = NewEvent()
@@ -1761,10 +1762,10 @@
self.goutput = GConsoleWindow(parent = self.notebook, gconsole = self._gconsole, margin = False)
self._gconsole.Bind(EVT_CMD_RUN,
lambda event:
- self._switchPageHandler(event = event, priority = 2))
+ self._switchPageHandler(event=event, notification=Notification.MAKE_VISIBLE))
self._gconsole.Bind(EVT_CMD_DONE,
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')
else:
self.goutput = None
@@ -1999,17 +2000,18 @@
# event is somehow propagated?
event.StopPropagation()
- def _switchPageHandler(self, event, priority):
- self._switchPage(priority = priority)
+ def _switchPageHandler(self, event, notification):
+ self._switchPage(notification=notification)
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')
- if priority >= 2:
+ if notification == Notification.MAKE_VISIBLE:
self.notebook.SetSelectionByName('output')
- if priority >= 3:
+ if notification == Notification.RAISE_WINDOW:
+ self.notebook.SetSelectionByName('output')
self.SetFocus()
self.Raise()
Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -36,7 +36,7 @@
from core.gcmd import GError, EncodeString
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
+ EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR, Notification
from gui_core.prompt import GPromptSTC
from core.settings import UserSettings
from core.utils import _
@@ -48,11 +48,6 @@
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):
"""!Create and manage output console for commands run by GUI.
"""
@@ -86,6 +81,10 @@
# signal which requests showing of a notification
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
self.progressbar = wx.Gauge(parent = self.panelProgress, id = wx.ID_ANY,
@@ -99,13 +98,12 @@
lambda event:
self.WriteLog(text = event.text,
wrap = event.wrap,
- switchPage = event.switchPage,
- priority = event.priority))
+ notification=event.notification))
self._gconsole.Bind(EVT_WRITE_CMD_LOG,
lambda event:
self.WriteCmdLog(line = event.line,
pid = event.pid,
- switchPage = event.switchPage))
+ notification=event.notification))
self._gconsole.Bind(EVT_WRITE_WARNING,
lambda event:
self.WriteWarning(line = event.line))
@@ -116,7 +114,6 @@
# text control for command output
self.cmdOutput = GStc(parent = self.panelOutput, id = wx.ID_ANY, margin = margin,
wrap = None)
- self.cmdOutput.Bind(stc.EVT_STC_CHANGE, self.OnStcChanged)
# search & command prompt
# move to the if below
@@ -305,19 +302,15 @@
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
given style
@param line text line
@param style text style (see GStc)
@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()
@@ -348,8 +341,10 @@
self.cmdOutput.SetStyling(p2 - p1, style)
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
@param line message to be printed
@@ -358,15 +353,15 @@
"""
if pid:
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):
"""!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):
"""!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):
"""!Clear content of output window"""
@@ -427,16 +422,16 @@
def OnCmdOutput(self, event):
"""!Print command output
-
- Posts event EVT_OUTPUT_TEXT with priority attribute set to 1.
"""
message = event.text
type = event.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):
"""!Update progress message info"""
@@ -505,10 +500,6 @@
def _hideProgress(self):
self.outputSizer.Hide(self.panelProgress)
self.outputSizer.Layout()
-
- def OnStcChanged(self, event):
- newEvent = gGcContentChanged()
- wx.PostEvent(self, newEvent)
def ResetFocus(self):
"""!Reset focus"""
Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/lmgr/frame.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -53,10 +53,9 @@
from modules.mcalc_builder import MapCalcFrame
from dbmgr.manager import AttributeManager
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 LocationDialog, MapsetDialog, CreateNewVector, GroupDialog
from modules.colorrules import RasterColorTable, VectorColorTable
@@ -292,33 +291,12 @@
self.goutput.showNotification.connect(lambda message: self.SetStatusText(message))
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,
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()
# create 'search module' notebook page
@@ -596,17 +574,18 @@
event.Skip()
- def _switchPageHandler(self, event, priority):
- self._switchPage(priority = priority)
+ def _switchPageHandler(self, event, notification):
+ self._switchPage(notification=notification)
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')
- if priority >= 2:
+ if notification == Notification.MAKE_VISIBLE:
self.notebook.SetSelectionByName('output')
- if priority >= 3:
+ if notification == Notification.RAISE_WINDOW:
+ self.notebook.SetSelectionByName('output')
self.SetFocus()
self.Raise()
@@ -868,7 +847,7 @@
SetAddOnPath(os.pathsep.join(addonPath), key = 'PATH')
self._gconsole.WriteCmdLog(_("Launching script '%s'...") % filename)
- self._gconsole.RunCmd([filename], switchPage = True)
+ self._gconsole.RunCmd([filename])
def OnChangeLocation(self, event):
"""Change current location"""
@@ -999,7 +978,7 @@
platform.python_version(),
wx.__version__,
_("Platform"), platform.platform().decode('utf8', 'replace'), osgeo4w),
- priority = 2)
+ notification=Notification.MAKE_VISIBLE)
self._gconsole.WriteCmdLog(' ')
def OnAboutGRASS(self, event):
Modified: grass/trunk/gui/wxpython/lmgr/giface.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/giface.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/lmgr/giface.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -16,6 +16,7 @@
"""
from grass.pydispatch.signal import Signal
+from core.giface import Notification
class Layer(object):
@@ -145,15 +146,15 @@
def Help(self, 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,
- 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):
self.lmgr._gconsole.WriteWarning(line = line)
Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -606,7 +606,7 @@
mapLayer = self.GetLayerInfo(self.layer_selected, key = 'maplayer')
cmd = ['v.build',
'map=%s' % mapLayer.GetName()]
- self._giface.RunCmd(cmd, switchPage = True)
+ self._giface.RunCmd(cmd)
def OnSqlQuery(self, event):
"""!Show SQL query window for PostGIS layers
@@ -631,7 +631,7 @@
cmd.append('map=%s' % mapLayer.GetName())
# print output to command log area
- self._giface.RunCmd(cmd, switchPage = True)
+ self._giface.RunCmd(cmd)
def OnSetCompRegFromRaster(self, event):
"""!Set computational region from selected raster map (ignore NULLs)"""
@@ -814,10 +814,10 @@
raster2d.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
if raster2d:
- self._giface.RunCmd(['r.univar', 'map=%s' % ','.join(raster2d)], switchPage=True)
+ self._giface.RunCmd(['r.univar', 'map=%s' % ','.join(raster2d)])
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):
"""!Print 2D statistics"""
@@ -828,7 +828,7 @@
rasters.append(self.GetLayerInfo(layer, key = 'maplayer').GetName())
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):
"""!Start editing vector map layer requested by the user
Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -58,6 +58,7 @@
from wxplot.scatter import ScatterFrame
from mapwin.analysis import ProfileController, MeasureDistanceController
from gui_core.forms import GUI
+from core.giface import Notification
from mapdisp import statusbar as sb
@@ -336,7 +337,7 @@
# erase map window
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)
# create GL window
@@ -410,7 +411,9 @@
key = 'statusbarMode',
subkey = 'selection'))
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:
self.MapWindow3D.OnClose(event = None)
# switch from MapWindowGL to MapWindow
@@ -735,9 +738,8 @@
def _onRedirectQueryOutput(self, output, style='log'):
"""!Writes query output into console"""
- # TODO: fix switching tab
if style == 'log':
- self._giface.WriteLog(output)
+ self._giface.WriteLog(output, notification=Notification.MAKE_VISIBLE)
elif style == 'cmd':
self._giface.WriteCmdLog(output)
Modified: grass/trunk/gui/wxpython/mapwin/analysis.py
===================================================================
--- grass/trunk/gui/wxpython/mapwin/analysis.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/mapwin/analysis.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -23,6 +23,7 @@
from core.utils import _
import core.units as units
+from core.giface import Notification
from grass.pydispatch.signal import Signal
@@ -279,6 +280,6 @@
_('total distance'), strtotdist, tdunits,
'-' * 60)
- self._giface.WriteLog(mstring, priority=2)
+ self._giface.WriteLog(mstring, notification=Notification.MAKE_VISIBLE)
return dist
Modified: grass/trunk/gui/wxpython/nviz/mapwindow.py
===================================================================
--- grass/trunk/gui/wxpython/nviz/mapwindow.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/nviz/mapwindow.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -44,6 +44,7 @@
from nviz import wxnviz
from core.globalvar import CheckWxVersion
from core.utils import str2rgb, _
+from core.giface import Notification
wxUpdateProperties, EVT_UPDATE_PROP = NewEvent()
wxUpdateView, EVT_UPDATE_VIEW = NewEvent()
@@ -2550,7 +2551,7 @@
def OnNvizCmd(self):
"""!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):
"""!This draws the DC to a buffer that can be saved to a file.
Modified: grass/trunk/gui/wxpython/scripts/vkrige.py
===================================================================
--- grass/trunk/gui/wxpython/scripts/vkrige.py 2013-10-21 12:29:40 UTC (rev 58085)
+++ grass/trunk/gui/wxpython/scripts/vkrige.py 2013-10-22 02:12:20 UTC (rev 58086)
@@ -41,6 +41,7 @@
from gui_core import goutput
from core.settings import UserSettings
from gui_core.widgets import GNotebook
+from core.giface import Notification
#import help
import wx
@@ -105,10 +106,10 @@
self.outpage = self.RPackagesBook.AddPage(page = self.goutput, text = _("Command output"), name = 'output')
self._gconsole.Bind(gconsole.EVT_CMD_RUN,
lambda event:
- self._switchPageHandler(event = event, priority = 2))
+ self._switchPageHandler(event=event, notification=Notification.MAKE_VISIBLE))
self._gconsole.Bind(gconsole.EVT_CMD_DONE,
lambda event:
- self._switchPageHandler(event = event, priority = 3))
+ self._switchPageHandler(event=event, notification=Notification.RAISE_WINDOW))
self.RPackagesBook.SetSelection(0)
KrigingSizer.Add(self.RPackagesBook, proportion = 1, flag = wx.EXPAND)
@@ -250,25 +251,27 @@
# give it to the output console
#@FIXME: it runs the command as a NEW instance. Reimports data, recalculates variogram fit..
#otherwise I can use Controller() and mimic RunCmd behaviour.
- self._gconsole.RunCmd(command, switchPage = True)
+ self._gconsole.RunCmd(command)
def OnVarianceCBChecked(self, event):
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()
- 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')
- if priority >= 2:
+ if notification == Notification.MAKE_VISIBLE:
self.RPackagesBook.SetSelectionByName('output')
- if priority >= 3:
+ if notification == Notification.RAISE_WINDOW:
+ self.RPackagesBook.SetSelectionByName('output')
self.SetFocus()
self.Raise()
+
class KrigingModule(wx.Frame):
""" Kriging module for GRASS GIS. Depends on R and its packages gstat and geoR. """
def __init__(self, parent, Rinstance, controller, *args, **kwargs):
More information about the grass-commit
mailing list