[GRASS-SVN] r38417 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 14 10:48:06 EDT 2009
Author: martinl
Date: 2009-07-14 10:48:06 -0400 (Tue, 14 Jul 2009)
New Revision: 38417
Modified:
grass/trunk/gui/wxpython/gui_modules/goutput.py
Log:
Make GMConsole working outside of wxGUI
(merge from devbr6, r38416)
Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-07-14 14:31:02 UTC (rev 38416)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py 2009-07-14 14:48:06 UTC (rev 38417)
@@ -112,19 +112,22 @@
self.requestCmd.abort()
class GMConsole(wx.Panel):
+ """!Create and manage output console for commands run by GUI.
"""
- Create and manage output console for commands entered on the
- GIS Manager command line.
- """
def __init__(self, parent, id=wx.ID_ANY, margin=False, pageid=0,
- pos=wx.DefaultPosition, size=wx.DefaultSize,
- style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE):
- wx.Panel.__init__(self, parent, id, pos, size, style)
+ notebook = None,
+ style=wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
+ **kwargs):
+ wx.Panel.__init__(self, parent, id, style = style, *kwargs)
self.SetName("GMConsole")
# initialize variables
self.Map = None
- self.parent = parent # GMFrame | CmdPanel
+ self.parent = parent # GMFrame | CmdPanel | ?
+ if notebook:
+ self._notebook = notebook
+ else:
+ self._notebook = self.parent.notebook
self.lineWidth = 80
self.pageid = pageid
# remember position of line begining (used for '\r')
@@ -240,8 +243,8 @@
@param stdout write to stdout or stderr
"""
if switchPage and \
- self.parent.notebook.GetSelection() != self.parent.goutput.pageid:
- self.parent.notebook.SetSelection(self.parent.goutput.pageid)
+ self._notebook.GetSelection() != self.parent.goutput.pageid:
+ self._notebook.SetSelection(self.parent.goutput.pageid)
if not style:
style = self.cmd_output.StyleDefault
@@ -376,8 +379,8 @@
# switch to 'Command output'
if switchPage:
- if self.parent.notebook.GetSelection() != self.parent.goutput.pageid:
- self.parent.notebook.SetSelection(self.parent.goutput.pageid)
+ if self._notebook.GetSelection() != self.parent.goutput.pageid:
+ self._notebook.SetSelection(self.parent.goutput.pageid)
self.parent.SetFocus() # -> set focus
self.parent.Raise()
@@ -464,12 +467,12 @@
"""!Print command output"""
message = event.text
type = event.type
- if self.parent.notebook.GetSelection() != self.parent.goutput.pageid:
- textP = self.parent.notebook.GetPageText(self.parent.goutput.pageid)
+ if self._notebook.GetSelection() != self.parent.goutput.pageid:
+ textP = self._notebook.GetPageText(self.parent.goutput.pageid)
if textP[-1] != ')':
textP += ' (...)'
- self.parent.notebook.SetPageText(self.parent.goutput.pageid,
- textP)
+ self._notebook.SetPageText(self.parent.goutput.pageid,
+ textP)
# message prefix
if type == 'warning':
@@ -583,8 +586,9 @@
if hasattr(self.parent.parent, "btn_help"):
dialog.btn_help.Enable(True)
- dialog.btn_run.Enable(True)
-
+ if hasattr(self.parent.parent, "btn_run"):
+ dialog.btn_run.Enable(True)
+
if event.returncode == 0 and \
not event.aborted and hasattr(dialog, "addbox") and \
dialog.addbox.IsChecked():
@@ -609,8 +613,9 @@
lcmd=lcmd,
lname=name)
- if dialog.get_dcmd is None and \
- dialog.closebox.IsChecked():
+ if hasattr(dialog, "get_dcmd") and \
+ dialog.get_dcmd is None and \
+ dialog.closebox.IsChecked():
time.sleep(1)
dialog.Close()
More information about the grass-commit
mailing list