[IPython-dev] embedding ipython

Piotr Zolnierczuk piotr.zolnierczuk at gmail.com
Wed May 12 11:48:44 EDT 2010


Fernando,

Thanks for the reply. I understand the delay - I have been there.

Is wxPython integration something that I could contribute perhaps? For
example I would like to have a configurable IPython shell widget that one
could just "drop" in into an app. The present example - as great as it is -
has some hard-coded stuff (fonts, etc) that I would like to see being
configurable. Also the user config that you mention is a great thing to
improve.
I will check the latest sources and see how can one make things better.

Thanks again

Piotr

On Wed, May 12, 2010 at 2:44 AM, Fernando Perez <fperez.net at gmail.com>wrote:

> Hi Piotr,
>
> sorry for the long delay; the git/github transition swallowed most of
> my ipython time for the last few days.  Thankfully we're over that now
> :)
>
> On Sun, Apr 25, 2010 at 11:29 AM, Piotr Zolnierczuk
> <piotr.zolnierczuk at gmail.com> wrote:
> > I have been using an embedded IPython shell (sorry I am still at 0.9.1)
> in a
> > wxPython app for quite some time and I (and my users) like very much.
> > I cloned IPython.gui.wx.ipython_view to customize look-and-feel with the
> > rest of my app.
> >
> > My app has a bunch of "GUI" tabs that control physics experiment hardware
> > (neutron scattering at Oak Ridge National Lab) and one tab that is the
> > IPython shell that allows for "custom" scripts. The main app needs to
> "pass"
> > some objects into the shell, for example an object that is responsible
> for
> > communication with the control hardware,
> > so it can be used in the interactive shell. I used user_ns dictionary for
> it
> > and it works for me.
>
> Yes, that's the intent of the user_ns dict.
>
> > Now I have a bunch of questions, so please bear with me:
> >
> > a) what is the difference between user_ns and user_global_ns  (in
> particular
> > in IPython.gui.wx.ipshell_nonblocking)?
>
> I'm not 100% sure about the wx one, but in general, those two exist
> because  in Python,  the exec statement's grammar:
>
> http://docs.python.org/reference/simple_stmts.html#exec
>
> supports *two* dictionaries  to resolve names, one for local names and
>  one for global ones.  This lets you control those separately.  I'm
> afraid I can't recall exact instances where using both is needed, but
> at least you know the purpose :)
>
> > b) the example (wxIPython) as well I my embedded shell do not fill _oh
> > dictionary and '_' is always empty so users cannot "recall" the results
> of
> > the previous statement. The ipython shell works fine in that respect. Why
> > wxIPython does not?
>
> I think the wx shell code doesn't completely implement the entire
> ipython machinery.  Laurent, the author of that code, may be able to
> help out better, though he's been fairly quiet as of late.
>
> > c) could "passing" of the objects  be done via 'configuration' file? If
> yes,
> > how?.
>
> In the pre-0.11 api, you could try to populate the user namespace with
> objects loaded via this config file:
>
>
> http://ipython.scipy.org/doc/stable/html/config/customization.html#ipy-user-conf-py
>
> though I have to admit I'm not 100% sure if the wxip loads that at startup
> time.
>
> In the 0.11  series we completely reworked the configuration system
> into something fairly clean and rational where this can be done (and
> if it doesn't work, we'll consider it a bug).  I'll announce plans for
> 0.11 shortly.
>
> > d) could an external app execute a script (function) via IPython shell?
>
> From another process, not out of the box today.  You'd need to wire
> some code inside your process that listens over a port/pipe and
> responds to commands.  But writing such bit of code isn't particularly
> hard, it just depends on whether you need only local behavior (case in
> which a simple named pipe may be enough) or  you need network support.
>
> > e) some users suggested a capability where user "queues" scripts and then
> > some kernel executes them one-by-one. Anybody knows a good python
> solution
> > for that?
>
> Well, the ipython distributed computing apis do much of that indeed:
>
> http://ipython.scipy.org/doc/stable/html/parallel/index.html
>
> Cheers,
>
> f
>



-- 

Piotr Adam Zolnierczuk
e-mail: piotr at zolnierczuk.net
www:   http://www.zolnierczuk.net
_____________________________________
written on recycled electrons
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20100512/8daff76a/attachment.html>


More information about the IPython-dev mailing list