##// END OF EJS Templates
* The SVG payload matplotlib backend now works....
* The SVG payload matplotlib backend now works. * Added RichIPythonWidget, which supports plot payloads. * Added Qt console demo applicaton. * Fixed calltips not being resized properly.

File last commit:

r2758:65912dee
r2758:65912dee
Show More
rich_ipython_widget.py
43 lines | 1.6 KiB | text/x-python | PythonLexer
# System library imports
from PyQt4 import QtCore, QtGui
# Local imports
from IPython.frontend.qt.util import image_from_svg
from ipython_widget import IPythonWidget
class RichIPythonWidget(IPythonWidget):
""" An IPythonWidget that supports rich text, including lists, images, and
tables. Note that raw performance will be reduced compared to the plain
text version.
"""
#---------------------------------------------------------------------------
# 'QObject' interface
#---------------------------------------------------------------------------
def __init__(self, parent=None):
""" Create a RichIPythonWidget.
"""
super(RichIPythonWidget, self).__init__(kind='rich', parent=parent)
#---------------------------------------------------------------------------
# 'FrontendWidget' interface
#---------------------------------------------------------------------------
def _handle_execute_payload(self, payload):
""" Reimplemented to handle pylab plot payloads.
"""
super(RichIPythonWidget, self)._handle_execute_payload(payload)
plot_payload = payload.get('plot', None)
if plot_payload and plot_payload['format'] == 'svg':
try:
image = image_from_svg(plot_payload['data'])
except ValueError:
self._append_plain_text('Received invalid plot data.')
else:
cursor = self._get_end_cursor()
cursor.insertBlock()
cursor.insertImage(image)
cursor.insertBlock()