[IPython-User] Fwd: adding control to notebook

Fernando Perez fperez.net@gmail....
Mon Apr 23 00:00:16 CDT 2012


Hi Zoltan,

I think you sent your reply off-list by accident, sending it back to
the list for the record...

---------- Forwarded message ----------
From: Zoltán Vörös <zvoros@gmail.com>
Date: Tue, Dec 27, 2011 at 2:13 PM
Subject: Re: [IPython-User] adding control to notebook
To: Fernando Perez <fperez.net@gmail.com>


Greetings Fernando,

Many thanks for the comments! Below are mine. Or, perhaps, I should
say that those are mostly questions.

> There are two related but separate problems here:
>
> 1. How to allow users to load their on JS so they can later make JS
> calls from within cells in the nb.  We need to sort out a clean
> mechanism for this, that avoids somehow collisions with the core
> functionality of the notebook itself.

To me this seems over-generous. I mean, letting the user load their
own JS and so on. Then the ipython notebook is going to evolve into a
JS frontend. What I had in mind (and this might very well fall into
the category that you labelled "the first hack that comes to mind") is
a generic JS that simply calls the corresponding python code. I
believe, there are probably only a finite number of types of
manipulation: button, slider, spinbutton... All these should just
retrieve a number or some other object, and call a python function
with those arguments. So, my idea was that one could just implement a
finite number of JS, belonging to the various types of manipulation,
and all these JS would just read out the state/value of all buttons,
sliders, spinbuttons and so on within a cell. (I think, one can assume
that one would want to manipulate within cells.) But I might
oversimplify things...

Of course, if you want to go further, e.g., make the figures also
interactive, that might be a different issue. Actually, interactive
figures are something that I miss a bit in the notebook. I see that I
can use the notebook "outline". I wonder whether this question has
come up in development. And whether an embeddable terminal, like the
canvas terminal of gnuplot could be a solution here. In other words,
what would be easier: make the notebook frontend be aware of a static
image, with coordinate tracking at least (zooming might be a bit
harder), or have a terminal based on JS directly from matplotlib? A
canvas terminal would have the advantage that it could be used
independent of ipython in the sense that one could just use the html
output, and ipython would not have to run. It could be great for web
pages, where one cannot run an ipython server. Anyway, if you think
that this could be useful, I could just look around at matplotlib, and
raise this issue with the developers there. In fact, it is quite easy
to turn an SVG file into a JS, so one could "hack" it, even if it was
not supported officially. But this might not fly with you.


> 2. How to let users present controls whose actions fire callbacks that
> act on the kernel side of things.  This is required by a
> Manipulate/@interact-like capability, because you want to recompute
> expressions in the kernel and show the updated results as the user
> moves the controls.

I am not sure I see the problem here. I don't mean to imply that this
is going to be plain sailing, but there are already buttons on the
notebook that operate on the kernel: the interrupt or restart buttons,
or the completer already interacts with the kernel. (Although, the
completer has only a checkbox, so it might not interact with anything,
after all.) The only difference is that these are "hard wired" into
the notebook, and cannot be changed at run-time.

> We just need to be patient and not implement the first hack that comes to mind
> :)

Right. And this is why I formulated my question as asking for hints. I
am really grateful for ipython in general, and I don't want to be seen
as someone whining about missing features and so on. I am willing to
invest some effort into making things happen, but I didn't know where
to start.
Cheers,
Zoltán


More information about the IPython-User mailing list