[IPython-dev] Printing support enabled

Evan Patterson epatters at enthought.com
Sat Oct 9 21:39:20 EDT 2010

Fernando has the right idea. Look at the _process_execute_payload,
_add_image, and _get_image methods of RichIPythonWidget to see how QImages
and SVG data are indexed. Since the QTextDocument does not have a mechanism
for retrieving all of it's resources, the image IDs will have to be stored
manually in '_add_image'.

If you prefer, I can implement this some time in the next week or so, but
feel free to take a stab at it.


On Sat, Oct 9, 2010 at 4:45 PM, Fernando Perez <fperez.net at gmail.com> wrote:

> On Sat, Oct 9, 2010 at 4:29 PM, Mark Voorhies <mark.voorhies at ucsf.edu>
> wrote:
> >
> > I think this would be easy. QTextEdit.toHtml() can dump the iPython
> > console as HTML, preserving mark-up.  The tricky bit is the images,
> > which get dumped like this:
> >
> > <img src="867583393794" />
> >
> > I'm assuming the number is Qt's internal ID for the image -- anyone
> > know how to map that back to the SVG/PNG objects in iPython?
> >
> > Given the image references, should be easy to either embed PNG or SVG
> > or do something like Firefox's "Web Page, complete" (obviously, embedding
> or
> > linking SVGs would be prettier, but runs into more browser compatibility
> > issues).
> >
> > If I can figure out how to resolve the IDs, I'll take a crack at this.
> Great, thanks!  You may want to look inside the payload handler that
> places the inline svgs.  That handler could perhaps get the qt id at
> that point, and store it in a dict member of the main object.  Upon
> saving, the dict would then easily be used to get back the reference
> to the image object, hence being able to write it out to disk in a
> foo_files/ directory like firefox does (or embedded in the html for
> single-file printouts, even better).
> Looking forward to your contributions!
> Cheers,
> f
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20101009/ac7d8774/attachment.html>

More information about the IPython-dev mailing list