Opened 11 years ago

Closed 8 years ago

Last modified 7 years ago

#666 closed enhancement (fixed)

add a scripting console

Reported by: timmie Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: wxGUI Version: svn-releasebranch64
Keywords: python Cc: epifanio, timmie
CPU: x86-32 Platform: All

Description

Please consider adding an IPython console to the wxGUI for scripting in the future

Change History (14)

comment:1 Changed 11 years ago by timmie

Type: defectenhancement

comment:2 Changed 11 years ago by hamish

Milestone: 6.4.07.0.0

comment:3 Changed 11 years ago by hamish

Keywords: python added

comment:4 Changed 8 years ago by martinl

Resolution: fixed
Status: newclosed

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

comment:5 Changed 7 years ago by timmie

Platform: LinuxAll
Version: unspecifiedsvn-releasebranch64

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.)

comment:6 Changed 7 years ago 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 … :) that can help me to get started

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

comment:7 Changed 7 years ago 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

comment:8 Changed 7 years ago by hamish

Cc: epifanio added

comment:9 in reply to:  7 ; Changed 7 years ago by annakrat

Replying to 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 example works at least, so it should be possible to make it work.

Anna

comment:10 in reply to:  6 Changed 7 years ago 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

comment:11 in reply to:  9 Changed 7 years ago by timmie

Replying to annakrat:

Replying to 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

comment:12 Changed 7 years ago 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

comment:13 Changed 7 years ago by timmie

Cc: timmie added

comment:14 Changed 7 years ago 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 here but is really old ...

Note: See TracTickets for help on using tickets.