[GRASS-SVN] r32320 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 26 16:28:36 EDT 2008
Author: martinl
Date: 2008-07-26 16:28:36 -0400 (Sat, 26 Jul 2008)
New Revision: 32320
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
Log:
wxGUI: redirecting messages fixed (merged from trunk, r32317)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-07-26 20:25:33 UTC (rev 32319)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2008-07-26 20:28:36 UTC (rev 32320)
@@ -388,6 +388,10 @@
self.notebook = notebook
self.pageid = pageid
+ self.type = ''
+ self.message = ''
+ self.printMessage = False
+
def write(self, s):
if self.pageid > -1:
# swith notebook page to 'command output'
@@ -397,13 +401,11 @@
s = s.replace('\n', os.linesep)
# remove/replace escape sequences '\b' or '\r' from stream
s = s.replace('\b', '').replace('\r', '%s' % os.linesep)
- type = ''
- message = ''
- printMessage = False
+
for line in s.split(os.linesep):
if len(line) == 0:
continue
-
+
if 'GRASS_INFO_PERCENT' in line:
# 'GRASS_INFO_PERCENT: 10' -> value=10
value = int(line.rsplit(':', 1)[1].strip())
@@ -412,23 +414,23 @@
else:
self.gmgauge.SetValue(0) # reset progress bar on '0%'
elif 'GRASS_INFO_MESSAGE' in line:
- type = 'message'
- if len(message) > 0:
- message += os.linesep
- message += line.split(':', 1)[1].strip()
+ self.type = 'message'
+ if len(self.message) > 0:
+ self.message += os.linesep
+ self.message += line.split(':', 1)[1].strip()
elif 'GRASS_INFO_WARNING' in line:
- type = 'warning'
- if len(message) > 0:
- message += os.linesep
- message += line.split(':', 1)[1].strip()
+ self.type = 'warning'
+ if len(self.message) > 0:
+ self.message += os.linesep
+ self.message += line.split(':', 1)[1].strip()
elif 'GRASS_INFO_ERROR' in line:
- type = 'error'
- if len(message) > 0:
- message += os.linesep
- message += line.split(':', 1)[1].strip()
+ self.type = 'error'
+ if len(self.message) > 0:
+ self.message += os.linesep
+ self.message += line.split(':', 1)[1].strip()
elif 'GRASS_INFO_END' in line:
- printMessage = True
- elif not type:
+ self.printMessage = True
+ elif not self.type:
if len(line) > 0:
p1 = self.gmstc.GetCurrentPos()
self.gmstc.AddTextWrapped(line, wrap=60) # wrap && add os.linesep
@@ -437,30 +439,30 @@
self.gmstc.StartStyling(p1, 0xff)
self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleUnknown)
elif len(line) > 0:
- message += os.linesep + line.strip()
+ self.message += os.linesep + line.strip()
- if printMessage and len(message) > 0:
+ if self.printMessage and len(self.message) > 0:
p1 = self.gmstc.GetCurrentPos()
- if type == 'warning':
- message = 'WARNING: ' + message
- elif type == 'error':
- message = 'ERROR: ' + message
- if os.linesep not in message:
- self.gmstc.AddTextWrapped(message, wrap=60) #wrap && add os.linesep
+ if self.type == 'warning':
+ self.message = 'WARNING: ' + self.message
+ elif self.type == 'error':
+ self.message = 'ERROR: ' + self.message
+ if os.linesep not in self.message:
+ self.gmstc.AddTextWrapped(self.message, wrap=60) #wrap && add os.linesep
else:
- self.gmstc.AddText(message + os.linesep)
+ self.gmstc.AddText(self.message + os.linesep)
# self.gmstc.EnsureCaretVisible()
p2 = self.gmstc.GetCurrentPos()
self.gmstc.StartStyling(p1, 0xff)
- if type == 'error':
+ if self.type == 'error':
self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleError)
- elif type == 'warning':
+ elif self.type == 'warning':
self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleWarning)
- elif type == 'message':
- self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleMessage)
+ elif self.type == 'self.message':
+ self.gmstc.SetStyling(p2 - p1 + 1, self.gmstc.StyleSelf.Message)
- type = ''
- message = ''
+ self.type = ''
+ self.message = ''
class GMStc(wx.stc.StyledTextCtrl):
"""Styled GMConsole
More information about the grass-commit
mailing list