|
@@ -198,7 +198,7 @@ class CmdThread(threading.Thread):
|
|
class GMConsole(wx.SplitterWindow):
|
|
class GMConsole(wx.SplitterWindow):
|
|
"""!Create and manage output console for commands run by GUI.
|
|
"""!Create and manage output console for commands run by GUI.
|
|
"""
|
|
"""
|
|
- def __init__(self, parent, id = wx.ID_ANY, margin = False,
|
|
|
|
|
|
+ def __init__(self, parent, frame, id = wx.ID_ANY, margin = False,
|
|
notebook = None,
|
|
notebook = None,
|
|
style = wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
|
|
style = wx.TAB_TRAVERSAL | wx.FULL_REPAINT_ON_RESIZE,
|
|
**kwargs):
|
|
**kwargs):
|
|
@@ -210,6 +210,7 @@ class GMConsole(wx.SplitterWindow):
|
|
|
|
|
|
# initialize variables
|
|
# initialize variables
|
|
self.parent = parent # GMFrame | CmdPanel | ?
|
|
self.parent = parent # GMFrame | CmdPanel | ?
|
|
|
|
+ self.frame = frame
|
|
if notebook:
|
|
if notebook:
|
|
self._notebook = notebook
|
|
self._notebook = notebook
|
|
else:
|
|
else:
|
|
@@ -285,7 +286,7 @@ class GMConsole(wx.SplitterWindow):
|
|
self.btnCmdProtocol.SetToolTipString(_("Toggle to save list of executed commands into file; "
|
|
self.btnCmdProtocol.SetToolTipString(_("Toggle to save list of executed commands into file; "
|
|
"content saved when switching off."))
|
|
"content saved when switching off."))
|
|
|
|
|
|
- if self.parent.GetName() != 'LayerManager':
|
|
|
|
|
|
+ if self.frame.GetName() != 'LayerManager':
|
|
self.btnCmdClear.Hide()
|
|
self.btnCmdClear.Hide()
|
|
self.btnCmdProtocol.Hide()
|
|
self.btnCmdProtocol.Hide()
|
|
|
|
|
|
@@ -329,7 +330,7 @@ class GMConsole(wx.SplitterWindow):
|
|
cmdBtnSizer.Add(item = self.btnCmdAbort, proportion = 1,
|
|
cmdBtnSizer.Add(item = self.btnCmdAbort, proportion = 1,
|
|
flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
|
|
flag = wx.ALIGN_CENTER | wx.RIGHT, border = 5)
|
|
|
|
|
|
- if self.parent.GetName() != 'LayerManager':
|
|
|
|
|
|
+ if self.frame.GetName() != 'LayerManager':
|
|
proportion = (1, 1)
|
|
proportion = (1, 1)
|
|
else:
|
|
else:
|
|
proportion = (2, 3)
|
|
proportion = (2, 3)
|
|
@@ -506,7 +507,7 @@ class GMConsole(wx.SplitterWindow):
|
|
except IOError, e:
|
|
except IOError, e:
|
|
GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") %
|
|
GError(_("Unable to write file '%(filePath)s'.\n\nDetails: %(error)s") %
|
|
{'filePath': filePath, 'error' : e },
|
|
{'filePath': filePath, 'error' : e },
|
|
- parent = self.parent)
|
|
|
|
|
|
+ parent = self.frame)
|
|
fileHistory = None
|
|
fileHistory = None
|
|
|
|
|
|
if fileHistory:
|
|
if fileHistory:
|
|
@@ -518,7 +519,7 @@ class GMConsole(wx.SplitterWindow):
|
|
if command[0] in globalvar.grassCmd:
|
|
if command[0] in globalvar.grassCmd:
|
|
# send GRASS command without arguments to GUI command interface
|
|
# send GRASS command without arguments to GUI command interface
|
|
# except display commands (they are handled differently)
|
|
# except display commands (they are handled differently)
|
|
- if self.parent.GetName() == "LayerManager" and \
|
|
|
|
|
|
+ if self.frame.GetName() == "LayerManager" and \
|
|
command[0][0:2] == "d." and \
|
|
command[0][0:2] == "d." and \
|
|
'help' not in ' '.join(command[1:]):
|
|
'help' not in ' '.join(command[1:]):
|
|
# display GRASS commands
|
|
# display GRASS commands
|
|
@@ -542,23 +543,23 @@ class GMConsole(wx.SplitterWindow):
|
|
'd.barscale' : 'barscale',
|
|
'd.barscale' : 'barscale',
|
|
'd.redraw' : 'redraw'}[command[0]]
|
|
'd.redraw' : 'redraw'}[command[0]]
|
|
except KeyError:
|
|
except KeyError:
|
|
- GMessage(parent = self.parent,
|
|
|
|
|
|
+ GMessage(parent = self.frame,
|
|
message = _("Command '%s' not yet implemented in the WxGUI. "
|
|
message = _("Command '%s' not yet implemented in the WxGUI. "
|
|
"Try adding it as a command layer instead.") % command[0])
|
|
"Try adding it as a command layer instead.") % command[0])
|
|
return
|
|
return
|
|
|
|
|
|
if layertype == 'barscale':
|
|
if layertype == 'barscale':
|
|
- self.parent.curr_page.maptree.GetMapDisplay().OnAddBarscale(None)
|
|
|
|
|
|
+ self.frame.GetLayerTree().GetMapDisplay().OnAddBarscale(None)
|
|
elif layertype == 'rastleg':
|
|
elif layertype == 'rastleg':
|
|
- self.parent.curr_page.maptree.GetMapDisplay().OnAddLegend(None)
|
|
|
|
|
|
+ self.frame.GetLayerTree().GetMapDisplay().OnAddLegend(None)
|
|
elif layertype == 'redraw':
|
|
elif layertype == 'redraw':
|
|
- self.parent.curr_page.maptree.GetMapDisplay().OnRender(None)
|
|
|
|
|
|
+ self.frame.GetLayerTree().GetMapDisplay().OnRender(None)
|
|
else:
|
|
else:
|
|
# add layer into layer tree
|
|
# add layer into layer tree
|
|
lname, found = utils.GetLayerNameFromCmd(command, fullyQualified = True,
|
|
lname, found = utils.GetLayerNameFromCmd(command, fullyQualified = True,
|
|
layerType = layertype)
|
|
layerType = layertype)
|
|
- if self.parent.GetName() == "LayerManager":
|
|
|
|
- self.parent.curr_page.maptree.AddLayer(ltype = layertype,
|
|
|
|
|
|
+ if self.frame.GetName() == "LayerManager":
|
|
|
|
+ self.frame.GetLayerTree().AddLayer(ltype = layertype,
|
|
lname = lname,
|
|
lname = lname,
|
|
lcmd = command)
|
|
lcmd = command)
|
|
|
|
|
|
@@ -602,8 +603,8 @@ class GMConsole(wx.SplitterWindow):
|
|
if switchPage:
|
|
if switchPage:
|
|
self._notebook.SetSelectionByName('output')
|
|
self._notebook.SetSelectionByName('output')
|
|
|
|
|
|
- self.parent.SetFocus()
|
|
|
|
- self.parent.Raise()
|
|
|
|
|
|
+ self.frame.SetFocus()
|
|
|
|
+ self.frame.Raise()
|
|
|
|
|
|
# activate computational region (set with g.region)
|
|
# activate computational region (set with g.region)
|
|
# for all non-display commands.
|
|
# for all non-display commands.
|
|
@@ -689,7 +690,7 @@ class GMConsole(wx.SplitterWindow):
|
|
GError(_("Unable to write file '%(path)s'.\n\nDetails: %(error)s") % {'path': path, 'error': e})
|
|
GError(_("Unable to write file '%(path)s'.\n\nDetails: %(error)s") % {'path': path, 'error': e})
|
|
finally:
|
|
finally:
|
|
output.close()
|
|
output.close()
|
|
- self.parent.SetStatusText(_("Commands output saved into '%s'") % path)
|
|
|
|
|
|
+ self.frame.SetStatusText(_("Commands output saved into '%s'") % path)
|
|
|
|
|
|
dlg.Destroy()
|
|
dlg.Destroy()
|
|
|
|
|
|
@@ -714,9 +715,9 @@ class GMConsole(wx.SplitterWindow):
|
|
"""!Update statusbar text"""
|
|
"""!Update statusbar text"""
|
|
if event.GetString():
|
|
if event.GetString():
|
|
nItems = len(self.cmdPrompt.GetCommandItems())
|
|
nItems = len(self.cmdPrompt.GetCommandItems())
|
|
- self.parent.SetStatusText(_('%d modules match') % nItems, 0)
|
|
|
|
|
|
+ self.frame.SetStatusText(_('%d modules match') % nItems, 0)
|
|
else:
|
|
else:
|
|
- self.parent.SetStatusText('', 0)
|
|
|
|
|
|
+ self.frame.SetStatusText('', 0)
|
|
|
|
|
|
event.Skip()
|
|
event.Skip()
|
|
|
|
|
|
@@ -733,7 +734,7 @@ class GMConsole(wx.SplitterWindow):
|
|
|
|
|
|
# message prefix
|
|
# message prefix
|
|
if type == 'warning':
|
|
if type == 'warning':
|
|
- messege = 'WARNING: ' + message
|
|
|
|
|
|
+ message = 'WARNING: ' + message
|
|
elif type == 'error':
|
|
elif type == 'error':
|
|
message = 'ERROR: ' + message
|
|
message = 'ERROR: ' + message
|
|
|
|
|
|
@@ -804,7 +805,7 @@ class GMConsole(wx.SplitterWindow):
|
|
finally:
|
|
finally:
|
|
output.close()
|
|
output.close()
|
|
|
|
|
|
- self.parent.SetStatusText(_("Commands protocol saved into '%s'") % self.cmdFileProtocol)
|
|
|
|
|
|
+ self.frame.SetStatusText(_("Commands protocol saved into '%s'") % self.cmdFileProtocol)
|
|
del self.cmdFileProtocol
|
|
del self.cmdFileProtocol
|
|
|
|
|
|
def OnCmdProtocol(self, event = None):
|
|
def OnCmdProtocol(self, event = None):
|
|
@@ -837,23 +838,23 @@ class GMConsole(wx.SplitterWindow):
|
|
|
|
|
|
def OnCmdRun(self, event):
|
|
def OnCmdRun(self, event):
|
|
"""!Run command"""
|
|
"""!Run command"""
|
|
- if self.parent.GetName() == 'Modeler':
|
|
|
|
- self.parent.OnCmdRun(event)
|
|
|
|
|
|
+ if self.frame.GetName() == 'Modeler':
|
|
|
|
+ self.frame.OnCmdRun(event)
|
|
|
|
|
|
self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
|
|
self.WriteCmdLog('(%s)\n%s' % (str(time.ctime()), ' '.join(event.cmd)))
|
|
self.btnCmdAbort.Enable()
|
|
self.btnCmdAbort.Enable()
|
|
|
|
|
|
def OnCmdPrepare(self, event):
|
|
def OnCmdPrepare(self, event):
|
|
"""!Prepare for running command"""
|
|
"""!Prepare for running command"""
|
|
- if self.parent.GetName() == 'Modeler':
|
|
|
|
- self.parent.OnCmdPrepare(event)
|
|
|
|
|
|
+ if self.frame.GetName() == 'Modeler':
|
|
|
|
+ self.frame.OnCmdPrepare(event)
|
|
|
|
|
|
event.Skip()
|
|
event.Skip()
|
|
|
|
|
|
def OnCmdDone(self, event):
|
|
def OnCmdDone(self, event):
|
|
"""!Command done (or aborted)"""
|
|
"""!Command done (or aborted)"""
|
|
- if self.parent.GetName() == 'Modeler':
|
|
|
|
- self.parent.OnCmdDone(event)
|
|
|
|
|
|
+ if self.frame.GetName() == 'Modeler':
|
|
|
|
+ self.frame.OnCmdDone(event)
|
|
|
|
|
|
# Process results here
|
|
# Process results here
|
|
try:
|
|
try:
|
|
@@ -890,13 +891,13 @@ class GMConsole(wx.SplitterWindow):
|
|
Debug.SetLevel()
|
|
Debug.SetLevel()
|
|
self.Redirect()
|
|
self.Redirect()
|
|
|
|
|
|
- if self.parent.GetName() == "LayerManager":
|
|
|
|
|
|
+ if self.frame.GetName() == "LayerManager":
|
|
self.btnCmdAbort.Enable(False)
|
|
self.btnCmdAbort.Enable(False)
|
|
if event.cmd[0] not in globalvar.grassCmd or \
|
|
if event.cmd[0] not in globalvar.grassCmd or \
|
|
event.cmd[0] == 'r.mapcalc':
|
|
event.cmd[0] == 'r.mapcalc':
|
|
return
|
|
return
|
|
|
|
|
|
- tree = self.parent.GetLayerTree()
|
|
|
|
|
|
+ tree = self.frame.GetLayerTree()
|
|
display = None
|
|
display = None
|
|
if tree:
|
|
if tree:
|
|
display = tree.GetMapDisplay()
|
|
display = tree.GetMapDisplay()
|
|
@@ -922,37 +923,37 @@ class GMConsole(wx.SplitterWindow):
|
|
if mapName in mapLayers:
|
|
if mapName in mapLayers:
|
|
display.GetWindow().UpdateMap(render = True)
|
|
display.GetWindow().UpdateMap(render = True)
|
|
return
|
|
return
|
|
- elif self.parent.GetName() == 'Modeler':
|
|
|
|
|
|
+ elif self.frame.GetName() == 'Modeler':
|
|
pass
|
|
pass
|
|
else: # standalone dialogs
|
|
else: # standalone dialogs
|
|
- dialog = self.parent.parent
|
|
|
|
- if hasattr(self.parent.parent, "btn_abort"):
|
|
|
|
|
|
+ dialog = self.frame
|
|
|
|
+ if hasattr(dialog, "btn_abort"):
|
|
dialog.btn_abort.Enable(False)
|
|
dialog.btn_abort.Enable(False)
|
|
|
|
|
|
- if hasattr(self.parent.parent, "btn_cancel"):
|
|
|
|
|
|
+ if hasattr(dialog, "btn_cancel"):
|
|
dialog.btn_cancel.Enable(True)
|
|
dialog.btn_cancel.Enable(True)
|
|
|
|
|
|
- if hasattr(self.parent.parent, "btn_clipboard"):
|
|
|
|
|
|
+ if hasattr(dialog, "btn_clipboard"):
|
|
dialog.btn_clipboard.Enable(True)
|
|
dialog.btn_clipboard.Enable(True)
|
|
|
|
|
|
- if hasattr(self.parent.parent, "btn_help"):
|
|
|
|
|
|
+ if hasattr(dialog, "btn_help"):
|
|
dialog.btn_help.Enable(True)
|
|
dialog.btn_help.Enable(True)
|
|
|
|
|
|
- if hasattr(self.parent.parent, "btn_run"):
|
|
|
|
|
|
+ if hasattr(dialog, "btn_run"):
|
|
dialog.btn_run.Enable(True)
|
|
dialog.btn_run.Enable(True)
|
|
|
|
|
|
if event.returncode == 0 and not event.aborted:
|
|
if event.returncode == 0 and not event.aborted:
|
|
try:
|
|
try:
|
|
- winName = self.parent.parent.parent.GetName()
|
|
|
|
|
|
+ winName = self.frame.parent.GetName()
|
|
except AttributeError:
|
|
except AttributeError:
|
|
winName = ''
|
|
winName = ''
|
|
|
|
|
|
if winName == 'LayerManager':
|
|
if winName == 'LayerManager':
|
|
- mapTree = self.parent.parent.parent.GetLayerTree()
|
|
|
|
|
|
+ mapTree = self.frame.parent.GetLayerTree()
|
|
elif winName == 'LayerTree':
|
|
elif winName == 'LayerTree':
|
|
- mapTree = self.parent.parent.parent
|
|
|
|
|
|
+ mapTree = self.frame.parent
|
|
elif winName: # GMConsole
|
|
elif winName: # GMConsole
|
|
- mapTree = self.parent.parent.parent.parent.GetLayerTree()
|
|
|
|
|
|
+ mapTree = self.frame.parent.parent.GetLayerTree()
|
|
else:
|
|
else:
|
|
mapTree = None
|
|
mapTree = None
|
|
|
|
|