<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 20, 2014 at 3:29 PM, Adam Hughes <span dir="ltr"><<a href="mailto:hughesadam87@gmail.com" target="_blank">hughesadam87@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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.</blockquote>

</div><div class="gmail_extra"><br></div>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.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">Here's how you can immediately write variables in ipython:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">In [7]: ip = get_ipython()</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">In [8]: a = 'hello'</div><div class="gmail_extra"><br></div><div class="gmail_extra">In [9]: ip.user_ns['a']</div><div class="gmail_extra">Out[9]: 'hello'</div>

<div class="gmail_extra"><br></div><div class="gmail_extra">In [10]: ip.user_ns['a'] = 100</div><div class="gmail_extra"><br></div><div class="gmail_extra">In [11]: a</div><div class="gmail_extra">Out[11]: 100</div>

<div><br></div><div><br></div><div>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.</div>

<div><br></div><div>Cheers</div><div><br></div><div>f</div><br clear="all"><div><br></div>-- <br>Fernando Perez (@fperez_org; <a href="http://fperez.org" target="_blank">http://fperez.org</a>)<br>fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)<br>

fernando.perez-at-berkeley: contact me here for any direct mail<br>
</div></div>