4 @brief wxGUI Interactive Python Shell for Layer Manager
7 - pyshell::PyShellWindow
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
14 This program is free software under the GNU General Public License
15 (>=v2). Read the file COPYING that comes with GRASS for details.
17 @author Martin Landa <landa.martin gmail.com>
23 from wx.py.shell
import Shell
as PyShell
24 from wx.py.version
import VERSION
29 """!Python Shell Window"""
30 def __init__(self, parent, id = wx.ID_ANY, **kwargs):
33 wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
35 self.
intro = _(
"Welcome to wxGUI Interactive Python Shell %s") % VERSION +
"\n\n" + \
36 _(
"Type %s for more GRASS scripting related information.") %
"\"help(grass)\"" +
"\n" + \
37 _(
"Type %s to add raster or vector to the layer tree.") %
"\"AddLayer()\"" +
"\n\n"
38 self.
shell = PyShell(parent = self, id = wx.ID_ANY,
39 introText = self.
intro, locals = {
'grass' : grass,
45 self.btnClear.Bind(wx.EVT_BUTTON, self.
OnClear)
46 self.btnClear.SetToolTipString(_(
"Delete all text from the shell"))
50 def _displayhook(self, value):
54 sizer = wx.BoxSizer(wx.VERTICAL)
56 sizer.Add(item = self.
shell, proportion = 1,
59 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
60 btnSizer.Add(item = self.
btnClear, proportion = 0,
61 flag = wx.EXPAND | wx.RIGHT, border = 5)
62 sizer.Add(item = btnSizer, proportion = 0,
63 flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
66 sizer.SetSizeHints(self)
71 self.SetAutoLayout(
True)
75 """!Add selected map to the layer tree
77 @param name name of raster/vector map to be added
78 @param type map type ('raster', 'vector', 'auto' for autodetection)
81 if ltype ==
'raster' or ltype !=
'vector':
83 fname = grass.find_file(name, element =
'cell')[
'fullname']
88 if not fname
and (ltype ==
'vector' or ltype !=
'raster'):
90 fname = grass.find_file(name, element =
'vector')[
'fullname']
96 return _(
"Raster or vector map <%s> not found") % (name)
98 self.parent.GetLayerTree().
AddLayer(ltype = ltype,
101 lcmd = [lcmd,
'map=%s' % fname])
102 if ltype ==
'raster':
103 return _(
'Raster map <%s> added') % fname
105 return _(
'Vector map <%s> added') % fname
108 """!Delete all text from the shell
111 self.shell.showIntro(self.
intro)
def AddLayer
Add selected map to the layer tree.
def OnClear
Delete all text from the shell.