Commit acb3230b authored by Luke Campagnola's avatar Luke Campagnola
Browse files

bugfix -- GraphicsItem automatically determines qt base class.

parent 3f486d9a
......@@ -15,12 +15,21 @@ class GraphicsItem(object):
The GraphicsView system places a lot of emphasis on the notion that the graphics within the scene should be device independent--you should be able to take the same graphics and display them on screens of different resolutions, printers, export to SVG, etc. This is nice in principle, but causes me a lot of headache in practice. It means that I have to circumvent all the device-independent expectations any time I want to operate in pixel coordinates rather than arbitrary scene coordinates. A lot of the code in GraphicsItem is devoted to this task--keeping track of view widgets and device transforms, computing the size and shape of a pixel in local item coordinates, etc. Note that in item coordinates, a pixel does not have to be square or even rectangular, so just asking how to increase a bounding rect by 2px can be a rather complex task.
def __init__(self, register=True):
if not hasattr(self, '_qtBaseClass'):
for b in self.__class__.__bases__:
if issubclass(b, QtGui.QGraphicsItem):
self.__class__._qtBaseClass = b
if not hasattr(self, '_qtBaseClass'):
raise Exception('Could not determine Qt base class for GraphicsItem: %s' % str(self))
self._viewWidget = None
self._viewBox = None
self._connectedView = None
if register:
GraphicsScene.registerObject(self) ## workaround for pyqt bug in graphicsscene.items()
def getViewWidget(self):
Return the view widget for this item. If the scene has multiple views, only the first view is returned.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment