[GRASS-SVN] r58088 - in grass/trunk/gui/wxpython: core gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 21 19:42:36 PDT 2013


Author: annakrat
Date: 2013-10-21 19:42:36 -0700 (Mon, 21 Oct 2013)
New Revision: 58088

Modified:
   grass/trunk/gui/wxpython/core/gconsole.py
   grass/trunk/gui/wxpython/core/giface.py
   grass/trunk/gui/wxpython/gui_core/goutput.py
Log:
wxGUI/gconsole: partial replace of events by signals (co-author: wenzeslaus)

Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2013-10-22 02:21:13 UTC (rev 58087)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2013-10-22 02:42:36 UTC (rev 58088)
@@ -325,13 +325,6 @@
             wx.PostEvent(self.receiver, evt)
 
 
-# events related to messages
-# TODO: create separete class for handling messages?
-gWriteLog, EVT_WRITE_LOG = NewEvent()
-gWriteCmdLog, EVT_WRITE_CMD_LOG = NewEvent()
-gWriteWarning, EVT_WRITE_WARNING = NewEvent()
-gWriteError, EVT_WRITE_ERROR = NewEvent()
-
 # Occurs when an ignored command is called.
 # Attribute cmd contains command (as a list).
 gIgnoredCmdRun, EVT_IGNORED_CMD_RUN = NewEvent()
@@ -352,6 +345,14 @@
         # Signal when some map is created or updated by a module.
         # attributes: name: map name, ltype: map type,
         self.mapCreated = Signal('GConsole.mapCreated')
+        # emitted when log message should be written
+        self.writeLog = Signal('GConsole.writeLog')
+        # emitted when command log message should be written
+        self.writeCmdLog = Signal('GConsole.writeCmdLog')
+        # emitted when warning message should be written
+        self.writeWarning = Signal('GConsole.writeWarning')
+        # emitted when error message should be written
+        self.writeError = Signal('GConsole.writeError')
 
         self._guiparent = guiparent
         self._giface = giface
@@ -398,9 +399,8 @@
         @param line text line
         @param notification form of notification
         """
-        event = gWriteLog(text=text, wrap=wrap,
+        self.writeLog.emit(text=text, wrap=wrap,
                           notification=notification)
-        wx.PostEvent(self, event)
 
     def WriteCmdLog(self, line, pid=None, notification=Notification.MAKE_VISIBLE):
         """!Write message in selected style
@@ -409,19 +409,16 @@
         @param pid process pid or None
         @param notification form of notification
         """
-        event = gWriteCmdLog(line=line, pid=pid,
-                             notification=notification)
-        wx.PostEvent(self, event)
+        self.writeCmdLog.emit(line=line, pid=pid,
+                              notification=notification)
 
     def WriteWarning(self, line):
         """!Write message in warning style"""
-        event = gWriteWarning(line=line)
-        wx.PostEvent(self, event)
+        self.writeWarning.emit(line=line)
 
     def WriteError(self, line):
         """!Write message in error style"""
-        event = gWriteError(line=line)
-        wx.PostEvent(self, event)
+        self.writeError.emit(line=line)
 
     def RunCmd(self, command, compReg=True, skipInterface=False,
                onDone=None, onPrepare=None, userData=None, notification=Notification.MAKE_VISIBLE):

Modified: grass/trunk/gui/wxpython/core/giface.py
===================================================================
--- grass/trunk/gui/wxpython/core/giface.py	2013-10-22 02:21:13 UTC (rev 58087)
+++ grass/trunk/gui/wxpython/core/giface.py	2013-10-22 02:42:36 UTC (rev 58088)
@@ -193,21 +193,17 @@
         # Signal emitted to request updating of map
         self.updateMap = Signal('StandaloneGrassInterface.updateMap')
 
+        # workaround, standalone grass interface should be moved to sep. file
         from core.gconsole import GConsole, \
-            EVT_CMD_OUTPUT, EVT_CMD_PROGRESS, \
-            EVT_WRITE_LOG, EVT_WRITE_CMD_LOG, EVT_WRITE_WARNING, EVT_WRITE_ERROR
+            EVT_CMD_OUTPUT, EVT_CMD_PROGRESS
 
         self._gconsole = GConsole()
         self._gconsole.Bind(EVT_CMD_PROGRESS, self._onCmdProgress)
         self._gconsole.Bind(EVT_CMD_OUTPUT, self._onCmdOutput)
-        self._gconsole.Bind(EVT_WRITE_LOG,
-                            lambda event: self.WriteLog(text=event.text))
-        self._gconsole.Bind(EVT_WRITE_CMD_LOG,
-                            lambda event: self.WriteCmdLog(line=event.line))
-        self._gconsole.Bind(EVT_WRITE_WARNING,
-                            lambda event: self.WriteWarning(line=event.line))
-        self._gconsole.Bind(EVT_WRITE_ERROR,
-                            lambda event: self.WriteError(line=event.line))
+        self._gconsole.writeLog.connect(self.WriteLog)
+        self._gconsole.writeCmdLog.connect(self.WriteCmdLog)
+        self._gconsole.writeWarning.connect(self.WriteWarning)
+        self._gconsole.writeError.connect(self.WriteError)
 
     def _onCmdOutput(self, event):
         """!Print command output"""

Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py	2013-10-22 02:21:13 UTC (rev 58087)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py	2013-10-22 02:42:36 UTC (rev 58088)
@@ -29,14 +29,13 @@
 
 import wx
 from   wx import stc
-from wx.lib.newevent import NewEvent
 
 from grass.pydispatch.signal import Signal
 
 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, Notification
+    Notification
 from gui_core.prompt import GPromptSTC
 from core.settings   import UserSettings
 from core.utils import _
@@ -94,23 +93,12 @@
         self._gconsole.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
         self._gconsole.Bind(EVT_CMD_RUN, self.OnCmdRun)
         self._gconsole.Bind(EVT_CMD_DONE, self.OnCmdDone)
-        self._gconsole.Bind(EVT_WRITE_LOG,
-                            lambda event:
-                                self.WriteLog(text = event.text,
-                                              wrap = event.wrap,
-                                              notification=event.notification))
-        self._gconsole.Bind(EVT_WRITE_CMD_LOG,
-                            lambda event:
-                                self.WriteCmdLog(line = event.line,
-                                                 pid = event.pid,
-                                                 notification=event.notification))
-        self._gconsole.Bind(EVT_WRITE_WARNING,
-                            lambda event:
-                                self.WriteWarning(line = event.line))
-        self._gconsole.Bind(EVT_WRITE_ERROR,
-                            lambda event:
-                                self.WriteError(line = event.line))
 
+        self._gconsole.writeLog.connect(self.WriteLog)
+        self._gconsole.writeCmdLog.connect(self.WriteCmdLog)
+        self._gconsole.writeWarning.connect(self.WriteWarning)
+        self._gconsole.writeError.connect(self.WriteError)
+
         # text control for command output
         self.cmdOutput = GStc(parent = self.panelOutput, id = wx.ID_ANY, margin = margin,
                                wrap = None)



More information about the grass-commit mailing list