Imported code for disabling ViewBox menus from Ingo
This commit is contained in:
parent
364337083f
commit
f9310d64c7
@ -193,6 +193,7 @@ class PlotItem(GraphicsWidget):
|
|||||||
'setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', 'setAutoVisible',
|
'setXRange', 'setYRange', 'setXLink', 'setYLink', 'setAutoPan', 'setAutoVisible',
|
||||||
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled',
|
'setRange', 'autoRange', 'viewRect', 'viewRange', 'setMouseEnabled',
|
||||||
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
|
'enableAutoRange', 'disableAutoRange', 'setAspectLocked',
|
||||||
|
'setMenuEnabled', 'menuEnabled',
|
||||||
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
'register', 'unregister']: ## NOTE: If you update this list, please update the class docstring as well.
|
||||||
setattr(self, m, getattr(self.vb, m))
|
setattr(self, m, getattr(self.vb, m))
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class ViewBox(GraphicsWidget):
|
|||||||
NamedViews = weakref.WeakValueDictionary() # name: ViewBox
|
NamedViews = weakref.WeakValueDictionary() # name: ViewBox
|
||||||
AllViews = weakref.WeakKeyDictionary() # ViewBox: None
|
AllViews = weakref.WeakKeyDictionary() # ViewBox: None
|
||||||
|
|
||||||
def __init__(self, parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, name=None):
|
def __init__(self, parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, enableMenu = True, name=None):
|
||||||
"""
|
"""
|
||||||
============= =============================================================
|
============= =============================================================
|
||||||
**Arguments**
|
**Arguments**
|
||||||
@ -103,6 +103,7 @@ class ViewBox(GraphicsWidget):
|
|||||||
|
|
||||||
'mouseEnabled': [enableMouse, enableMouse],
|
'mouseEnabled': [enableMouse, enableMouse],
|
||||||
'mouseMode': ViewBox.PanMode if pyqtgraph.getConfigOption('leftButtonPan') else ViewBox.RectMode,
|
'mouseMode': ViewBox.PanMode if pyqtgraph.getConfigOption('leftButtonPan') else ViewBox.RectMode,
|
||||||
|
'enableMenu': enableMenu,
|
||||||
'wheelScaleFactor': -1.0 / 8.0,
|
'wheelScaleFactor': -1.0 / 8.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +252,13 @@ class ViewBox(GraphicsWidget):
|
|||||||
def mouseEnabled(self):
|
def mouseEnabled(self):
|
||||||
return self.state['mouseEnabled'][:]
|
return self.state['mouseEnabled'][:]
|
||||||
|
|
||||||
|
def setMenuEnabled(self, enableMenu=True):
|
||||||
|
self.state['enableMenu'] = enableMenu
|
||||||
|
self.sigStateChanged.emit(self)
|
||||||
|
|
||||||
|
def menuEnabled(self):
|
||||||
|
return self.state.get('enableMenu', True)
|
||||||
|
|
||||||
def addItem(self, item, ignoreBounds=False):
|
def addItem(self, item, ignoreBounds=False):
|
||||||
"""
|
"""
|
||||||
Add a QGraphicsItem to this view. The view will include this item when determining how to set its range
|
Add a QGraphicsItem to this view. The view will include this item when determining how to set its range
|
||||||
@ -822,7 +830,7 @@ class ViewBox(GraphicsWidget):
|
|||||||
|
|
||||||
|
|
||||||
def mouseClickEvent(self, ev):
|
def mouseClickEvent(self, ev):
|
||||||
if ev.button() == QtCore.Qt.RightButton:
|
if ev.button() == QtCore.Qt.RightButton and self.menuEnabled():
|
||||||
ev.accept()
|
ev.accept()
|
||||||
self.raiseContextMenu(ev)
|
self.raiseContextMenu(ev)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user