[GRASS-SVN] r46488 - in
grass/branches/releasebranch_6_4/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jun 1 15:47:43 EDT 2011
Author: martinl
Date: 2011-06-01 12:47:43 -0700 (Wed, 01 Jun 2011)
New Revision: 46488
Added:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gpyshell.py
Modified:
grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/goutput.py
grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
Log:
wxGUI: implement interactive python shell
(merge r46485 & r46486 from trunk)
Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/goutput.py 2011-06-01 19:44:06 UTC (rev 46487)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/goutput.py 2011-06-01 19:47:43 UTC (rev 46488)
@@ -601,10 +601,9 @@
self.history += '\n'
wildcard = "Text file (*.txt)|*.txt"
- dlg = wx.FileDialog(
- self, message=_("Save file as..."), defaultDir=os.getcwd(),
- defaultFile="grass_cmd_history.txt", wildcard=wildcard,
- style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
+ dlg = wx.FileDialog(self, message = _("Save file as..."), defaultDir = os.getcwd(),
+ defaultFile = "grass_cmd_history.txt", wildcard = wildcard,
+ style = wx.SAVE | wx.FD_OVERWRITE_PROMPT)
# Show the dialog and retrieve the user response. If it is the OK response,
# process the data.
Copied: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gpyshell.py (from rev 46485, grass/trunk/gui/wxpython/gui_modules/gpyshell.py)
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gpyshell.py (rev 0)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/gpyshell.py 2011-06-01 19:47:43 UTC (rev 46488)
@@ -0,0 +1,75 @@
+"""!
+ at package gpyshell.py
+
+ at brief wxGUI Interactive Python Shell
+
+Classes:
+ - PyShellWindow
+
+(C) 2011 by the GRASS Development Team
+This program is free software under the GNU General Public
+License (>=v2). Read the file COPYING that comes with GRASS
+for details.
+
+ at author Martin Landa <landa.martin gmail.com>
+"""
+
+import os
+import sys
+
+import wx
+from wx.py.shell import Shell as PyShell
+from wx.py.version import VERSION
+
+import grass.script as grass
+
+class PyShellWindow(wx.Panel):
+ """!Python Shell Window"""
+ def __init__(self, parent, id = wx.ID_ANY, **kwargs):
+ self.parent = parent
+
+ wx.Panel.__init__(self, parent = parent, id = id, **kwargs)
+
+ self.intro = _("Welcome to wxGUI Interactive Python Shell %s") % VERSION + "\n\n" + \
+ _("Type %s for more GRASS scripting related information.") % "\"help(grass)\"" + "\n\n"
+ self.shell = PyShell(parent = self, id = wx.ID_ANY,
+ introText = self.intro, locals = {'grass' : grass})
+
+ sys.displayhook = self._displayhook
+
+ self.btnClear = wx.Button(self, wx.ID_CLEAR)
+ self.btnClear.Bind(wx.EVT_BUTTON, self.OnClear)
+ self.btnClear.SetToolTipString(_("Delete all text from the shell"))
+
+ self._layout()
+
+ def _displayhook(self, value):
+ print value # do not modify __builtin__._
+
+ def _layout(self):
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ sizer.Add(item = self.shell, proportion = 1,
+ flag = wx.EXPAND)
+
+ btnSizer = wx.BoxSizer(wx.HORIZONTAL)
+ btnSizer.Add(item = self.btnClear, proportion = 0,
+ flag = wx.EXPAND | wx.RIGHT, border = 5)
+ sizer.Add(item = btnSizer, proportion = 0,
+ flag = wx.ALIGN_RIGHT | wx.ALL, border = 5)
+
+ sizer.Fit(self)
+ sizer.SetSizeHints(self)
+
+ self.SetSizer(sizer)
+
+ self.Fit()
+ self.SetAutoLayout(True)
+ self.Layout()
+
+ def OnClear(self, event):
+ """!Delete all text from the shell
+ """
+ self.shell.clear()
+ self.shell.showIntro(self.intro)
+ self.shell.prompt()
Modified: grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py 2011-06-01 19:44:06 UTC (rev 46487)
+++ grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py 2011-06-01 19:47:43 UTC (rev 46488)
@@ -81,10 +81,11 @@
from gui_modules import gmodeler
from gui_modules import vclean
from gui_modules import nviz_tools
-from gui_modules.debug import Debug
-from gui_modules.ghelp import MenuTreeWindow, AboutWindow, InstallExtensionWindow
+from gui_modules.debug import Debug
+from gui_modules.ghelp import MenuTreeWindow, AboutWindow, InstallExtensionWindow
from gui_modules.toolbars import LayerManagerToolbar, ToolsToolbar
-from icons.icon import Icons
+from gui_modules.gpyshell import PyShellWindow
+from icons.icon import Icons
UserSettings = preferences.globalSettings
@@ -220,7 +221,7 @@
self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY, agwStyle = globalvar.FNPageDStyle)
else:
self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY, style = globalvar.FNPageDStyle)
-
+
# create displays notebook widget and add it to main notebook page
cbStyle = globalvar.FNPageStyle
if globalvar.hasAgw:
@@ -230,7 +231,7 @@
self.gm_cb.SetTabAreaColour(globalvar.FNPageColor)
self.notebook.AddPage(self.gm_cb, text = _("Map layers"))
- # create command output text area and add it to main notebook page
+ # create 'command output' text area
self.goutput = goutput.GMConsole(self, pageid = 1)
self.notebook.AddPage(self.goutput, text = _("Command console"))
@@ -238,10 +239,14 @@
self.search = MenuTreeWindow(parent = self)
self.notebook.AddPage(self.search, text = _("Search module"))
+ # create 'python shell' notebook page
+ self.pyshell = PyShellWindow(parent = self)
+ self.notebook.AddPage(self.pyshell, text = _("Python shell"))
+
# bindings
- self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnCBPageChanged)
+ self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnCBPageChanged)
self.notebook.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosed)
+ self.gm_cb.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosed)
return self.notebook
More information about the grass-commit
mailing list