Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: qt.rich_text

Defines classes and functions for working with Qt’s rich text system.

1 Class

class IPython.qt.rich_text.HtmlExporter(control)

Bases: object

A stateful HTML exporter for a Q(Plain)TextEdit.

This class is designed for convenient user interaction.

__init__(control)

Creates an HtmlExporter for the given Q(Plain)TextEdit.

export()

Displays a dialog for exporting HTML generated by Qt’s rich text system.

Returns:The name of the file that was saved, or None if no file was saved.

4 Functions

IPython.qt.rich_text.export_html(html, filename, image_tag=None, inline=True)

Export the contents of the ConsoleWidget as HTML.

Parameters:

html : unicode,

A Python unicode string containing the Qt HTML to export.

filename : str

The file to be saved.

image_tag : callable, optional (default None)

Used to convert images. See default_image_tag() for information.

inline : bool, optional [default True]

If True, include images as inline PNGs. Otherwise, include them as links to external PNG files, mimicking web browsers’ “Web Page, Complete” behavior.

IPython.qt.rich_text.export_xhtml(html, filename, image_tag=None)

Export the contents of the ConsoleWidget as XHTML with inline SVGs.

Parameters:

html : unicode,

A Python unicode string containing the Qt HTML to export.

filename : str

The file to be saved.

image_tag : callable, optional (default None)

Used to convert images. See default_image_tag() for information.

IPython.qt.rich_text.default_image_tag(match, path=None, format='png')

Return (X)HTML mark-up for the image-tag given by match.

This default implementation merely removes the image, and exists mostly for documentation purposes. More information than is present in the Qt HTML is required to supply the images.

Parameters:

match : re.SRE_Match

A match to an HTML image tag as exported by Qt, with match.group(“Name”) containing the matched image ID.

path : string|None, optional [default None]

If not None, specifies a path to which supporting files may be written (e.g., for linked images). If None, all images are to be included inline.

format : “png”|”svg”, optional [default “png”]

Format for returned or referenced images.

IPython.qt.rich_text.fix_html(html)

Transforms a Qt-generated HTML string into a standards-compliant one.

Parameters:

html : unicode,

A Python unicode string containing the Qt HTML.