[GRASS-dev] [GRASS GIS] #666: add a scripting console

#666: add a scripting console
--------------------+-------------------------------------------------------
Reporter: timmie | Owner: grass-dev@lists.osgeo.org
     Type: defect | Status: new
Priority: normal | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Keywords: | Platform: Linux
      Cpu: x86-32 |
--------------------+-------------------------------------------------------
Please consider adding an IPython console to the wxGUI for scripting in
the future

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 6.4.0
Component: wxGUI | Version: unspecified
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by timmie):

  * type: defect => enhancement

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: unspecified
Resolution: | Keywords:
  Platform: Linux | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by hamish):

  * milestone: 6.4.0 => 7.0.0

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@lists.osgeo.org
      Type: enhancement | Status: new
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: unspecified
Resolution: | Keywords: python
  Platform: Linux | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by hamish):

  * keywords: => python

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: unspecified
Resolution: fixed | Keywords: python
  Platform: Linux | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by martinl):

  * status: new => closed
  * resolution: => fixed

Comment:

Available as "Python shell" in wxGUI (see 6.4.3+). Closing this ticket.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by timmie):

  * platform: Linux => All
  * version: unspecified => svn-releasebranch64

Comment:

Excuse me for pluggin in again on this.
What do you think about making this shell IPython-aware.

So if a users has IPython installed, it would then offer all its comfort
and capabilities (plotting, %magics, existing plugins, R-interface, etc.)

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by neteler):

From grass-dev:

On Sun, Nov 11, 2012 at 11:34 PM, Massimo Di Stefano:
> http://nbviewer.ipython.org/url/epi.whoi.edu/esr/GIS_GRASS-
R_Example.ipynb
>
> essentially i found it a really easy and effective way to use grass from
a
> web page, but it runs pretty well also from localhost of course.
>
> i'd love to write a grass gui plug-in to integrate the IPython Notebook
> inside the WX-gui in GRASS
> maybe a simple wx frame that embed an http link to where the notebook is
> running + an init script to lunch the notebook
> before to start to coding something ( i'm pretty new to WX and its
"grass
> internals" )
> i was wondering if there is any interest on doing this from the GRASS
gui
> guru … :slight_smile: that can help me to get started

See http://lists.osgeo.org/pipermail/grass-dev/2012-November/060768.html

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by timmie):

So does this mean agreement or disagreement?

the notebook is a beast that could not get integrated.
We would rather need to create a set of %magics to open the wxGui from
within the IPython Notebook to
* get the power of scripting with GRASS, R, Scipy etc.
* use the power & comfort of GRASS wxGUI for display and interaction.

=> this would be a different enhancement request.

But here' a gui example:
https://github.com/ipython/ipython/blob/master/examples/lib/ipkernel_wxapp.py

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/666#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by hamish):

* cc: epifanio (added)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by annakrat):

Replying to [comment:7 timmie]:
> So does this mean agreement or disagreement?
>
> the notebook is a beast that could not get integrated.
> We would rather need to create a set of %magics to open the wxGui from
within the IPython Notebook to
> * get the power of scripting with GRASS, R, Scipy etc.
> * use the power & comfort of GRASS wxGUI for display and interaction.
>
> => this would be a different enhancement request.
>
> But here' a gui example:
>
https://github.com/ipython/ipython/blob/master/examples/lib/ipkernel_wxapp.py

This console is based on qt. It would be possible to call it and use it as
a separate window. However, so far I was not able launch it from wxGUI
because of various errors. Also it seems that the console (from the
example above) does not quit with the wx app. Maybe someone will be more
lucky.

I haven't succeeded in launching wxGUI from IPython either. The GUI
freezes. The [https://github.com/ipython/ipython/blob/master/examples/lib
/gui-wx.py example] works at least, so it should be possible to make it
work.

Anna

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by timmie):

> On Sun, Nov 11, 2012 at 11:34 PM, Massimo Di Stefano:
> > http://nbviewer.ipython.org/url/epi.whoi.edu/esr/GIS_GRASS-
R_Example.ipynb
[...]
Since this is beyond this ticket, please follow up here:

create IPython magic to control from IPython Notebook
https://trac.osgeo.org/grass/ticket/1921

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by timmie):

Replying to [comment:9 annakrat]:
> Replying to [comment:7 timmie]:

[...]
> > But here' a gui example:
> >
https://github.com/ipython/ipython/blob/master/examples/lib/ipkernel_wxapp.py
>
> This console is based on qt. It would be possible to call it and use it
as a separate window. However, so far I was not able launch it from wxGUI
because of various errors. Also it seems that the console (from the
example above) does not quit with the wx app. Maybe someone will be more
lucky.

I think you are talking of the IPython QT Console.

Since this is beyond this ticket, please follow up here:

create IPython magic to launch GRASS wxGUI components Ipython qt console
https://trac.osgeo.org/grass/ticket/1920

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by timmie):

Ok, since this ticket here is closed, please follow up on the new
enhancement ticket:

use IPython for python Shell in wxGui if
installedhttps://trac.osgeo.org/grass/ticket/1922

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------
Changes (by timmie):

* cc: timmie (added)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#666: add a scripting console
--------------------------+-------------------------------------------------
  Reporter: timmie | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: wxGUI | Version: svn-releasebranch64
Resolution: fixed | Keywords: python
  Platform: All | Cpu: x86-32
--------------------------+-------------------------------------------------

Comment(by epifanio):

Annakrat that is correct, those examples are for embedding the IPython
*kernel*, not UI.

IMHO, try to embed the notebbok is worth to try (much powerful and easier
to implement than the standard IPython shell)
in wx 2.9 a simple code like :

{{{
import wx
import wx.html2

app = wx.App(False)
frame = wx.Frame(None, -1, 'A Simple Frame')
browser = wx.html2.WebView.New(frame)
browser.LoadURL("http://IP:PORT/NoetebookName.ipynb")
frame.Show()
app.MainLoop()
}}}

will open a wx frame within the notebbok.
# the problem here is wx2.9 ...

We can have a "notebook dashboard" written in a WX frame as part of the
grass wx gui, something like :

{{{
#!/usr/local/bin/python

import sys

import wx

import wx.html2

class MyFrame(wx.Frame):
     def __init__(self, parent, title):
         wx.Frame.__init__(self, parent, -1, title,
                           pos=(150, 150), size=(350, 285))
         menuBar = wx.MenuBar()
         menu = wx.Menu()
         menu.Append(wx.ID_EXIT, "E&xit\tAlt-X", "Exit")
         menuBar.Append(menu, "&File")
         self.SetMenuBar(menuBar)
         self.CreateStatusBar()
         panel = wx.Panel(self)
         text = wx.StaticText(panel, -1, "Notebook Browser")
         text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
         text.SetSize(text.GetBestSize())

         NoetebookName_btn = wx.Button(panel, -1, "NoetebookName")
         self.Bind(wx.EVT_BUTTON, self.showBrowser, NoetebookName_btn)
         sizer = wx.BoxSizer(wx.VERTICAL)
         for ctrl in [text, browser_btn]:
             sizer.Add(ctrl, 0, wx.ALL, 10)
         panel.SetSizer(sizer)
         panel.Layout()

     def showBrowser(self, evt):
         app = wx.App(False)
         frame = wx.Frame(None, -1, 'A Simple Frame')
         browser = wx.html2.WebView.New(frame)
         browser.LoadURL("http://IP:PORT/NoetebookName.ipynb")
         frame.Show()

class MyApp(wx.App):
     def OnInit(self):
         frame = MyFrame(None, "Simple wxPython App")
         self.SetTopWindow(frame)
         frame.Show(True)
         return True

if __name__ == '__main__':
     app = MyApp(redirect=False, clearSigInt=False)
     app.MainLoop()
}}}

Instead of a single button, we'll have (auto generated) buttons for each
notebook avalable in the IPython notebook dir, and open a new tab in the
wx-dashboard-frame when a button is pressed
(notebook dir is in the ipython_notebook_config.py
"c.FileNotebookManager.notebook_dir")

Hope make sense ...
if looking for an "ancient" wx-gui for ipython .. i found something here
[https://code.google.com/p/editra-plugins/wiki/IPythonShellPlugin here]
but is really old ...

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/666#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>