[IPython-dev] loading a static JS file when loading an IPython extension in the notebook

MinRK benjaminrk at gmail.com
Sat Jul 12 12:20:31 EDT 2014


On Fri, Jul 11, 2014 at 8:38 AM, Nicholas Bollweg <nick.bollweg at gmail.com>
wrote:

> Here's the most recent thread on that:
>
> http://python.6.x6.nabble.com/Loading-nbextension-on-widget-instantiation-tt5060760.html#none
>
> I captured some of the pattens into a cookiecutter template:
> https://github.com/bollwyvl/cookiecutter-ipython-widget
>

Very nice! We should probably have something like this in the IPython docs.


>
>
> You can use this pattern, even if you aren't using widgets, though.
>
> The key chores are:
>
>    - make sure your static files, in a folder, get copied on install
>    (MANIFEST.in)
>    - when you are ready to use your JS, copy static into the nbextensions directory
>    (in the users profile) with
>    IPython.html.nbextensions.install_nbextension
>    - display them (and/or any css) with display
>
>
> Here is the file I use for encapsulating those steps:
>
> https://github.com/bollwyvl/cookiecutter-ipython-widget/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.pkg_name%7D%7D/widgets/mixins.py
> It gets called each time an instance of a class is instantiated. It was
> suggested that this is preferable over loading it at import time.
>
>  Hope this helps!
>
>
> On Thu, Jul 10, 2014 at 8:48 AM, Cyrille Rossant <
> cyrille.rossant at gmail.com> wrote:
>
>> Hi,
>>
>> What is the best way to write an IPython extension such that
>> `%load_ext myext` loads `myscript.js` in the current notebook? If
>> possible, I'd prefer to avoid asking users to make manual changes to
>> custom.js or similar.
>>
>> Thanks,
>> Cyrille
>> _______________________________________________
>> IPython-dev mailing list
>> IPython-dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-dev
>>
>
>
> _______________________________________________
> 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/20140712/47c32814/attachment.html>


More information about the IPython-dev mailing list