[IPython-dev] Feasilibity of widgets/layout for mimicking this

Fernando Perez fperez.net at gmail.com
Wed Aug 20 19:07:05 EDT 2014


On Wed, Aug 20, 2014 at 3:29 PM, Adam Hughes <hughesadam87 at gmail.com> wrote:

> These widgets would need to accept input data, and return output data.
>  For example in the example Nicholas shared, I'd like the user to be able
> to pass in a matrix, calculate the synchronous spectra, and then use that
> for further analysis in subsequent cells in the primary notebook.  Having
> that as a capability would be huge for us, because we envision a mixed
> API/GUI workflow.


One option here would be to provide a text field for the user to name the
variables they want returned for any given output (or you can fix those if
you want), and then have your kernel-side code store them in the user's
namespace directly.

Here's how you can immediately write variables in ipython:

In [7]: ip = get_ipython()

In [8]: a = 'hello'

In [9]: ip.user_ns['a']
Out[9]: 'hello'

In [10]: ip.user_ns['a'] = 100

In [11]: a
Out[11]: 100


We can think further about whether other paradigms might be cleaner, but
I'm not sure that making variables be the return value of the widget itself
will work all that well. But in the meantime, and until we decide what the
best solution is in the long term, this will already work and it uses a
100% stable IPython api. It may be in the end this *is* a long-term
solution we all like, but even if not, I think it's pretty serviceable.

Cheers

f


-- 
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140820/0416ce9f/attachment.html>


More information about the IPython-dev mailing list