Move common code to _applyEnableMenu
This commit is contained in:
parent
a84953530f
commit
50cf2f561f
@ -321,13 +321,7 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
self.state.update(state)
|
||||
|
||||
if self.state['enableMenu'] and self.menu is None:
|
||||
self.menu = ViewBoxMenu(self)
|
||||
self.updateViewLists()
|
||||
elif not self.state['enableMenu'] and self.menu is not None:
|
||||
self.menu.setParent(None)
|
||||
self.menu = None
|
||||
|
||||
self._applyMenuEnabled()
|
||||
self.updateViewRange()
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
@ -381,16 +375,20 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
def setMenuEnabled(self, enableMenu=True):
|
||||
self.state['enableMenu'] = enableMenu
|
||||
self._applyMenuEnabled()
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
def menuEnabled(self):
|
||||
return self.state.get('enableMenu', True)
|
||||
|
||||
def _applyMenuEnabled(self):
|
||||
enableMenu = self.state.get("enableMenu", True)
|
||||
if enableMenu and self.menu is None:
|
||||
self.menu = ViewBoxMenu(self)
|
||||
self.updateViewLists()
|
||||
elif not enableMenu and self.menu is not None:
|
||||
self.menu.setParent(None)
|
||||
self.menu = None
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
def menuEnabled(self):
|
||||
return self.state.get('enableMenu', True)
|
||||
|
||||
def addItem(self, item, ignoreBounds=False):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user