[IPython-dev] Best approach for uploading files through the Notebook?

Carl Smith carl.input at gmail.com
Wed Jun 27 17:42:08 EDT 2012


Thanks Brian. That's perfect. Nice one.
On Jun 27, 2012 9:21 PM, "Brian Granger" <ellisonbg at gmail.com> wrote:

> Let's say you want to create an %upload magic for this purpose.
>
> 1. First create a magic function using this approach:
>
>
> http://ipython.org/ipython-doc/dev/interactive/reference.html#defining-your-own-magics
>
> 2. Your magic function should do something like this:
>
> from IPython.core.display import display, Javascript
>
> display(Javascript('your JS code goes here'))
>
> 3. Then you need to write the JS code to open the file browser, read
> the file and send it back to the kernel using kernel.execute.
>
> On Wed, Jun 27, 2012 at 1:14 PM, Carl Smith <carl.input at gmail.com> wrote:
> > I want to have a go at doing what Matthius proposed, but need a few
> > pointers. I know I can use IPython.notebook.kernel.execute in the
> > JavaScript to control the kernel. Is this the only method for the
> > JavaScript to chat to the kernel?
>
> Yep, basically.
>
> > I also don't know how to get the kernel to channel data back to the
> > JavaScript. I know Brian demonstrated that this can be done, but I
> > can't find any example code that covers it. I read somewhere that it
> > required some changes to the Notebook, and there was a PR for this, is
> > this still true, or does the current dev version support this stuff
> > out the box?
>
> The dev version supports everything you need.
>
> Cheers,
>
> Brian
>
> > Thanks Matthius for your help on this issue, and to everyone on the
> > list for your patience, I do appreciate it very much.
> >
> > Carl
> > _______________________________________________
> > IPython-dev mailing list
> > IPython-dev at scipy.org
> > http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
> --
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> bgranger at calpoly.edu and ellisonbg at gmail.com
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120627/20de21ee/attachment.html>


More information about the IPython-dev mailing list