##// 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:

r2757:c7455244 merge
r2758:65912dee
Show More
util.py
64 lines | 1.9 KiB | text/x-python | PythonLexer
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 """ Defines miscellaneous Qt-related helper classes and functions.
"""
# System library imports.
epatters
Initial checkin of (not yet working) matplotlib payload backend and associated machinery.
r2756 from PyQt4 import QtCore, QtGui
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
# IPython imports.
from IPython.utils.traitlets import HasTraits
epatters
Initial checkin of (not yet working) matplotlib payload backend and associated machinery.
r2756 #-----------------------------------------------------------------------------
# Metaclasses
#-----------------------------------------------------------------------------
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
MetaHasTraits = type(HasTraits)
MetaQObject = type(QtCore.QObject)
Brian Granger
Merge branch 'epatters-qtfrontend' into kernelmanager...
r2726 # You can switch the order of the parents here and it doesn't seem to matter.
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643 class MetaQObjectHasTraits(MetaQObject, MetaHasTraits):
""" A metaclass that inherits from the metaclasses of both HasTraits and
QObject.
Using this metaclass allows a class to inherit from both HasTraits and
QObject. See QtKernelManager for an example.
"""
epatters
* Added 'req_port' option to 'launch_kernel' and the kernel entry point....
r2702 pass
epatters
Initial checkin of (not yet working) matplotlib payload backend and associated machinery.
r2756
#-----------------------------------------------------------------------------
# Functions
#-----------------------------------------------------------------------------
epatters
* Added 'started_listening' and 'stopped_listening' signals to QtKernelManager. The FrontendWidget listens for these signals....
r2643
epatters
Initial checkin of (not yet working) matplotlib payload backend and associated machinery.
r2756 def image_from_svg(string, size=None):
""" Convert a string containing SVG data into a QImage.
Parameters:
-----------
string : str
A Python string containing the SVG data.
size : QSize or None [default None]
The size of the image that is produced. If not specified, the SVG data's
default size is used.
Raises:
-------
ValueError
If an invalid SVG string is provided.
Returns:
--------
A QImage with format QImage.Format_ARGB32_Premultiplied.
"""
from PyQt4 import QtSvg
bytes = QtCore.QByteArray(string)
renderer = QtSvg.QSvgRenderer(bytes)
if not renderer.isValid():
raise ValueError('Invalid SVG data.')
if size is None:
size = renderer.defaultSize()
image = QtGui.QImage(size, QtGui.QImage.Format_ARGB32_Premultiplied)
painter = QtGui.QPainter(image)
renderer.render(painter)
return image