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

GRASS GIS trac at osgeo.org
Sat Apr 6 05:33:06 PDT 2013


#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>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list