From 6255dca99cd8ed3dc94ff086ec65df3f45b20c65 Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Wed, 26 Feb 2014 10:20:24 -0500 Subject: [PATCH] MouseClickEvent: sometimes __repr__ could cause an exception This happens during debugging session in an IDE (eric5) when debugger inspects variables but self._scenePos is not yet initialized. --- pyqtgraph/GraphicsScene/mouseEvents.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/GraphicsScene/mouseEvents.py b/pyqtgraph/GraphicsScene/mouseEvents.py index f337a657..fa9bc36d 100644 --- a/pyqtgraph/GraphicsScene/mouseEvents.py +++ b/pyqtgraph/GraphicsScene/mouseEvents.py @@ -221,9 +221,12 @@ class MouseClickEvent(object): return self._modifiers def __repr__(self): - p = self.pos() - return "" % (p.x(), p.y(), int(self.button())) - + try: + p = self.pos() + return "" % (p.x(), p.y(), int(self.button())) + except: + return "" % (int(self.button())) + def time(self): return self._time