[IPython-dev] writing notebook extensions compatible with IPython.load_extensions
Matthias Bussonnier
bussonniermatthias at gmail.com
Sun Jun 29 11:07:03 EDT 2014
Hi Max
Le 29 juin 2014 à 15:39, Max Linke a écrit :
> `IPython.load_extensions('test');`.
Where do you do that ?
>
> This is the code I have in ~/.ipython/nbextensions/test.js
>
> IPython.toolbar.add_buttons_group([
> {
> 'label' : 'test',
> 'icon' : 'icon-moon',
> 'id' : 'test-button'
> }
> ]);
>
> When I use this the js-console of chromium gives the following error
This works for me in master when copied past into Chrome console on IPython 3.0-dev.
>
> Uncaught TypeError: Cannot read property 'add_buttons_group' of
> undefined
>
> But if I load test.js in custom.js like this it works.
>
> $([IPython.events]).on('app_initialized.NotebookApp',function(){
> require(['nbextensions/test.js']);
> });
>
> What do I have to add to test.js so that the js functions in the IPython
> namespace are not undefined?
It is probably just a race condition :
> $([IPython.events]).on('app_initialized.NotebookApp',function(){
> IPython.load_extensions('test');
> });
Should work as IPython.load_extensions is just a simple wrapper around require.
--
M
More information about the IPython-dev
mailing list