[IPython-dev] Detecting ipython notebook on the browser

Tiago Antao tra at popgen.net
Fri May 23 07:19:38 EDT 2014


Before my question proper, a bit of proselytising ;) 

While a few of us around here are scientists I do think that IPython
Notebook would be an amazing tool for the arts (i.e. computer assisted
generation). Consider all the tweaking and real-time changing
allowed by ipython notebook applied to music, drawing, animation, ...

In this context I have been working on integrating abjad (a score
composition software) with Ipython notebook. There is currently a
solution that is 99% transparent and you can find that here:


Now, I want to submit a patch to abjad in order to make this 100%
transparent (i.e. propose a change that would make abjad work with
ipython notebook out of the box).

The way things work now is by overriding abjad's show function: instead
of generating a postscript file and firing a postscript viewer I
generate a PNG file and send it (after some cropping) to ipython
notebook. Instead of overriding the show function, the function itself
could decide what to do based on context...

So, what I needed to know is:

1. How to detect that ipython notebook is running?

2. A bit more subtle than that: Can I detect that it is running in a
browser context? I mean: we can run a notebook from the command line
(with the %run magic) and in that case I might still want to generate a
PS instead of a PNG file...

PS - I am interested in extending the notebook metaphor to
creative/artistic stuff. If you have an ongoing project/idea on this,
and need some volunteer hands, get in touch...

More information about the IPython-dev mailing list