4 @brief wxGUI Interactive Python Shell
9 @todo run pyshell and evaluate code in a separate instance of python
10 & design the widget communicate back and forth with it
12 (C) 2011 by the GRASS Development Team
13 This program is free software under the GNU General Public
14 License (>=v2). Read the file COPYING that comes with GRASS
17 @author Martin Landa <landa.martin gmail.com>
24 from wx.py.shell
import Shell
as PyShell
25 from wx.py.version
import VERSION
30 """!Python Shell Window"""
31 def __init__(self, parent, id = wx.ID_ANY, **kwargs):
34 wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
36 self.
intro = _(
"Welcome to wxGUI Interactive Python Shell %s") % VERSION +
"\n\n" + \
37 _(
"Type %s for more GRASS scripting related information.") %
"\"help(grass)\"" +
"\n" + \
38 _(
"Type %s to add raster or vector to the layer tree.") %
"\"AddLayer()\"" +
"\n\n"
39 self.
shell = PyShell(parent = self, id = wx.ID_ANY,
40 introText = self.
intro, locals = {
'grass' : grass,
46 self.btnClear.Bind(wx.EVT_BUTTON, self.
OnClear)
47 self.btnClear.SetToolTipString(_(
"Delete all text from the shell"))
51 def _displayhook(self, value):
55 sizer = wx.BoxSizer(wx.VERTICAL)
57 sizer.Add(item = self.
shell, proportion = 1,
60 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
61 btnSizer.Add(item = self.
btnClear, proportion = 0,
62 flag = wx.EXPAND | wx.RIGHT, border = 5)
63 sizer.Add(item = btnSizer, proportion = 0,
64 flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
67 sizer.SetSizeHints(self)
72 self.SetAutoLayout(
True)
76 """!Add selected map to the layer tree
78 @param name name of raster/vector map to be added
79 @param type map type ('raster', 'vector', 'auto' for autodetection)
82 if ltype ==
'raster' or ltype !=
'vector':
84 fname = grass.find_file(name, element =
'cell')[
'fullname']
89 if not fname
and (ltype ==
'vector' or ltype !=
'raster'):
91 fname = grass.find_file(name, element =
'vector')[
'fullname']
97 return _(
"Raster or vector map <%s> not found") % (name)
99 self.parent.GetLayerTree().
AddLayer(ltype = ltype,
102 lcmd = [lcmd,
'map=%s' % fname])
103 if ltype ==
'raster':
104 return _(
'Raster map <%s> added') % fname
106 return _(
'Vector map <%s> added') % fname
109 """!Delete all text from the shell
112 self.shell.showIntro(self.
intro)