From ef2ffdd88cb154d2da44306b9b9e5c3ec1b6cf62 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 14 Nov 2013 14:01:25 -0500 Subject: [PATCH] Fixed bug: ViewBox context menu elements are no longer deleted when using flowchart + pyside --- pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py b/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py index bbb40efc..5242ecdd 100644 --- a/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py +++ b/pyqtgraph/graphicsItems/ViewBox/ViewBoxMenu.py @@ -65,8 +65,18 @@ class ViewBoxMenu(QtGui.QMenu): self.leftMenu = QtGui.QMenu("Mouse Mode") group = QtGui.QActionGroup(self) - pan = self.leftMenu.addAction("3 button", self.set3ButtonMode) - zoom = self.leftMenu.addAction("1 button", self.set1ButtonMode) + + # This does not work! QAction _must_ be initialized with a permanent + # object as the parent or else it may be collected prematurely. + #pan = self.leftMenu.addAction("3 button", self.set3ButtonMode) + #zoom = self.leftMenu.addAction("1 button", self.set1ButtonMode) + pan = QtGui.QAction("3 button", self.leftMenu) + zoom = QtGui.QAction("1 button", self.leftMenu) + self.leftMenu.addAction(pan) + self.leftMenu.addAction(zoom) + pan.triggered.connect(self.set3ButtonMode) + zoom.triggered.connect(self.set1ButtonMode) + pan.setCheckable(True) zoom.setCheckable(True) pan.setActionGroup(group)