[GRASS-SVN] r53925 - in grass/trunk/gui/wxpython: gmodeler gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Nov 19 13:55:13 PST 2012
Author: wenzeslaus
Date: 2012-11-19 13:55:12 -0800 (Mon, 19 Nov 2012)
New Revision: 53925
Modified:
grass/trunk/gui/wxpython/gmodeler/frame.py
grass/trunk/gui/wxpython/gui_core/goutput.py
Log:
wxGUI/GConsole: removing Modeler specific code, Modeler now uses events (co-author: annakrat)
Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py 2012-11-19 21:16:48 UTC (rev 53924)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py 2012-11-19 21:55:12 UTC (rev 53925)
@@ -34,7 +34,8 @@
from core import globalvar
from gui_core.widgets import GNotebook
-from gui_core.goutput import GConsole, EVT_OUTPUT_TEXT
+from gui_core.goutput import GConsole, \
+ EVT_CMD_RUN, EVT_CMD_DONE, EVT_CMD_PREPARE, EVT_OUTPUT_TEXT
from core.debug import Debug
from core.gcmd import GMessage, GException, GWarning, GError, RunCommand
from gui_core.dialogs import GetImageHandlers
@@ -106,7 +107,10 @@
self.goutput = GConsole(parent = self, frame = self)
self.goutput.Bind(EVT_OUTPUT_TEXT, self.OnOutputText)
-
+ self.Bind(EVT_CMD_RUN, self.OnCmdRun)
+ self.Bind(EVT_CMD_DONE, self.OnCmdDone)
+ self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
+
self.notebook.AddPage(page = self.canvas, text=_('Model'), name = 'model')
self.notebook.AddPage(page = self.itemPanel, text=_('Items'), name = 'items')
self.notebook.AddPage(page = self.variablePanel, text=_('Variables'), name = 'variables')
Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py 2012-11-19 21:16:48 UTC (rev 53924)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py 2012-11-19 21:55:12 UTC (rev 53925)
@@ -67,7 +67,10 @@
class CmdThread(threading.Thread):
"""!Thread for GRASS commands"""
requestId = 0
- def __init__(self, parent, requestQ = None, resultQ = None, **kwds):
+ def __init__(self, receiver, requestQ = None, resultQ = None, **kwds):
+ """!
+ @param receiver event receiver (used in PostEvent)
+ """
threading.Thread.__init__(self, **kwds)
if requestQ is None:
@@ -82,7 +85,7 @@
self.setDaemon(True)
- self.parent = parent # GConsole
+ self.receiver = receiver
self._want_abort_all = False
self.start()
@@ -128,13 +131,13 @@
pid = requestId,
onPrepare = vars()['onPrepare'],
userData = vars()['userData'])
- wx.PostEvent(self.parent, event)
+ wx.PostEvent(self.receiver, event)
# run command
event = wxCmdRun(cmd = args[0],
pid = requestId)
- wx.PostEvent(self.parent, event)
+ wx.PostEvent(self.receiver, event)
time.sleep(.1)
self.requestCmd = vars()['callable'](*args, **kwds)
@@ -190,7 +193,7 @@
userData = vars()['userData'])
# send event
- wx.PostEvent(self.parent, event)
+ wx.PostEvent(self.receiver, event)
def abort(self, abortall = True):
"""!Abort command(s)"""
@@ -249,11 +252,10 @@
self.cmdOutput = GStc(parent = self.panelOutput, id = wx.ID_ANY, margin = margin,
wrap = None)
self.cmdOutputTimer = wx.Timer(self.cmdOutput, id = wx.ID_ANY)
- self.cmdOutput.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
- self.cmdOutput.Bind(wx.EVT_TIMER, self.OnProcessPendingOutputWindowEvents)
+ self.Bind(EVT_CMD_OUTPUT, self.OnCmdOutput)
+ self.Bind(wx.EVT_TIMER, self.OnProcessPendingOutputWindowEvents)
self.Bind(EVT_CMD_RUN, self.OnCmdRun)
self.Bind(EVT_CMD_DONE, self.OnCmdDone)
- self.Bind(EVT_CMD_PREPARE, self.OnCmdPrepare)
# information about available modules
modulesData = ModulesData()
@@ -817,24 +819,14 @@
def OnCmdRun(self, event):
"""!Run command"""
- if self.frame.GetName() == 'Modeler':
- self.frame.OnCmdRun(event)
-
self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
self.btnCmdAbort.Enable()
- def OnCmdPrepare(self, event):
- """!Prepare for running command"""
- if self.frame.GetName() == 'Modeler':
- self.frame.OnCmdPrepare(event)
-
event.Skip()
-
+
def OnCmdDone(self, event):
"""!Command done (or aborted)"""
- if self.frame.GetName() == 'Modeler':
- self.frame.OnCmdDone(event)
-
+
# Process results here
try:
ctime = time.time() - event.time
@@ -998,8 +990,11 @@
Copyright: (c) 2005-2007 Jean-Michel Fauth
Licence: GPL
"""
- def __init__(self, parent):
- self.parent = parent # GConsole
+ def __init__(self, receiver):
+ """!
+ @param receiver event receiver (used in PostEvent)
+ """
+ self.receiver = receiver
def write(self, s):
if len(s) == 0 or s == '\n':
@@ -1011,7 +1006,7 @@
evt = wxCmdOutput(text = line + '\n',
type = '')
- wx.PostEvent(self.parent.cmdOutput, evt)
+ wx.PostEvent(self.receiver, evt)
class GStderr:
"""!GConsole standard error output
@@ -1024,8 +1019,11 @@
Copyright: (c) 2005-2007 Jean-Michel Fauth
Licence: GPL
"""
- def __init__(self, parent):
- self.parent = parent # GConsole
+ def __init__(self, receiver):
+ """!
+ @param receiver event receiver (used in PostEvent)
+ """
+ self.receiver = receiver
self.type = ''
self.message = ''
@@ -1067,14 +1065,14 @@
continue
evt = wxCmdOutput(text = line,
type = '')
- wx.PostEvent(self.parent.cmdOutput, evt)
+ wx.PostEvent(self.receiver, evt)
elif len(line) > 0:
self.message += line.strip() + '\n'
if self.printMessage and len(self.message) > 0:
evt = wxCmdOutput(text = self.message,
type = self.type)
- wx.PostEvent(self.parent.cmdOutput, evt)
+ wx.PostEvent(self.receiver, evt)
self.type = ''
self.message = ''
@@ -1084,7 +1082,7 @@
if progressValue > -1:
# self.gmgauge.SetValue(progressValue)
evt = wxCmdProgress(value = progressValue)
- wx.PostEvent(self.parent.progressbar, evt)
+ wx.PostEvent(self.receiver, evt)
class GStc(stc.StyledTextCtrl):
"""!Styled text control for GRASS stdout and stderr.
More information about the grass-commit
mailing list