[IPython-dev] first experiment creating Software Carpentry teaching materials using the IPython Notebook

MinRK benjaminrk@gmail....
Sun Mar 24 14:32:23 CDT 2013


On Sun, Mar 24, 2013 at 12:08 PM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

>
> Le 24 mars 2013 à 19:51, MinRK a écrit :
>
> >>
> >> With one clarification on #2:  There is not a hook for you to add css
> classes to the cells live in the notebook, but this can certainly be added.
>  The cell metadata is how you would do this, but interpreting the metadata
> to add the class to the div will need to be added.
> > Understood --- but that seems like it _ought_ to be a pretty simple
> extension (he said hopefully).
> >
> > It certainly should be - one thing we would need to do to support such
> an extension is add a hook for the 'cell-metadata-changed' event.
>
> No need to, the setters provided by the extensions just have to emit
> events.
>
> To take back an example from
> http://elacave.lmdb.eu/~carreau/yui/classes/IPython.CellToolbar.html
>
> (setters and getters are defined inline, but they could be provided
> separately and be imported )
>
>      * @example
>      *
>      *      var select_type = CellToolbar.utils.select_ui_generator([
>      *              ["<None>"            , undefined      ],
>      *              ["Header Slide" , "header_slide" ],
>      *              ["Slide"        , "slide"        ],
>      *              ["Fragment"     , "fragment"     ],
>      *              ["Skip"         , "skip"         ],
>      *              ],
>      *              // setter
>      *              function(cell, value){
>      *                  // we check that the slideshow namespace exist and
> create it if needed
>      *                  if (cell.metadata.slideshow ==
> undefined){cell.metadata.slideshow = {}}
>      *                  // set the value
>      *                  // ONE CAN EMMIT THE CHANGED VALUE HERE
>      *                  cell.metadata.slideshow.slide_type = value
>      *                  },
>      *              //geter
>      *              function(cell){ var ns = cell.metadata.slideshow;
>      *                  // if the slideshow namespace does not exist
> return `undefined`
>      *                  // (will be interpreted as `false` by checkbox)
> otherwise
>      *                  // return the value
>      *                  return (ns == undefined)? undefined: ns.slide_type
>      *                  }
>      *      CellToolbar.register_callback('slideshow.select', select_type);
>      *
>      */
>
> This allow people to rely on other plugin, and the plugin author can
> change the way the metadata are store/read al long as the getters/setters
> are exposed.
> See what I mean ? Or I should write an example ?
>

That's exactly what I was expecting, I just didn't know it was done already.
Thanks!


>
> --
> Matthias
>
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20130324/6867417e/attachment.html 


More information about the IPython-dev mailing list