<div dir="ltr"><div><div><div>Here's the most recent thread on that:<br><a href="http://python.6.x6.nabble.com/Loading-nbextension-on-widget-instantiation-tt5060760.html#none">http://python.6.x6.nabble.com/Loading-nbextension-on-widget-instantiation-tt5060760.html#none</a><br>
<br></div>I captured some of the pattens into a cookiecutter template:<br><a href="https://github.com/bollwyvl/cookiecutter-ipython-widget">https://github.com/bollwyvl/cookiecutter-ipython-widget</a><br><br></div><div>You can use this pattern, even if you aren't using widgets, though. <br>
<br></div><div>The key chores are:<br></div><div><ul><li>make sure your static files, in a folder, get copied on install (MANIFEST.in)</li><li>when you are ready to use your JS, copy static into the <span style="font-family:courier new,monospace">nbextensions </span>directory (in the users profile) with <span style="font-family:courier new,monospace">IPython.html.nbextensions.install_nbextension</span></li>
<li>display them (and/or any css) with <span style="font-family:courier new,monospace">display</span></li></ul></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<span style="font-family:courier new,monospace"><span class="" style="color:rgb(51,51,51);font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:18px;text-align:start;text-indent:0px;text-transform:none;white-space:pre;word-spacing:0px;background-color:rgb(255,255,255)"></span></span></blockquote>
</div><div><br>Here is the file<i> </i>I use for encapsulating those steps:<br><a href="https://github.com/bollwyvl/cookiecutter-ipython-widget/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.pkg_name%7D%7D/widgets/mixins.py">https://github.com/bollwyvl/cookiecutter-ipython-widget/blob/master/%7B%7Bcookiecutter.repo_name%7D%7D/%7B%7Bcookiecutter.pkg_name%7D%7D/widgets/mixins.py</a><br>
</div><div>It gets called each time an instance of a class is instantiated. It was suggested that this is preferable over loading it at <span style="font-family:courier new,monospace">import </span>time. <br><br></div><div>
Hope this helps!<br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 10, 2014 at 8:48 AM, Cyrille Rossant <span dir="ltr"><<a href="mailto:cyrille.rossant@gmail.com" target="_blank">cyrille.rossant@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
What is the best way to write an IPython extension such that<br>
`%load_ext myext` loads `myscript.js` in the current notebook? If<br>
possible, I'd prefer to avoid asking users to make manual changes to<br>
custom.js or similar.<br>
<br>
Thanks,<br>
Cyrille<br>
_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
</blockquote></div><br></div>