PlotItem: Fix enableMenu setting when passing a viewbox (#1496)
* PlotItem: enableMenu setting when passing a viewbox
This commit is contained in:
parent
386dcf8180
commit
2affe322ec
@ -136,10 +136,12 @@ class PlotItem(GraphicsWidget):
|
|||||||
self.layout.setVerticalSpacing(0)
|
self.layout.setVerticalSpacing(0)
|
||||||
|
|
||||||
if viewBox is None:
|
if viewBox is None:
|
||||||
viewBox = ViewBox(parent=self)
|
viewBox = ViewBox(parent=self, enableMenu=enableMenu)
|
||||||
self.vb = viewBox
|
self.vb = viewBox
|
||||||
self.vb.sigStateChanged.connect(self.viewStateChanged)
|
self.vb.sigStateChanged.connect(self.viewStateChanged)
|
||||||
self.setMenuEnabled(enableMenu, enableMenu) ## en/disable plotitem and viewbox menus
|
|
||||||
|
# Enable or disable plotItem menu
|
||||||
|
self.setMenuEnabled(enableMenu, None)
|
||||||
|
|
||||||
if name is not None:
|
if name is not None:
|
||||||
self.vb.register(name)
|
self.vb.register(name)
|
||||||
|
@ -21,3 +21,36 @@ def test_PlotItem_shared_axis_items(orientation):
|
|||||||
|
|
||||||
with pytest.raises(RuntimeError):
|
with pytest.raises(RuntimeError):
|
||||||
pi2.setAxisItems({orientation: ax1})
|
pi2.setAxisItems({orientation: ax1})
|
||||||
|
|
||||||
|
|
||||||
|
def test_plotitem_menu_initialize():
|
||||||
|
"""Test the menu initialization of the plotitem"""
|
||||||
|
item = pg.PlotItem()
|
||||||
|
assert item.menuEnabled() is True
|
||||||
|
viewbox = item.vb
|
||||||
|
assert viewbox is not None
|
||||||
|
assert viewbox.menu is not None
|
||||||
|
assert viewbox.menuEnabled() is True
|
||||||
|
|
||||||
|
item = pg.PlotItem(enableMenu=False)
|
||||||
|
assert item.menuEnabled() is False
|
||||||
|
viewbox = item.vb
|
||||||
|
assert viewbox is not None
|
||||||
|
assert viewbox.menu is None
|
||||||
|
assert viewbox.menuEnabled() is False
|
||||||
|
|
||||||
|
viewbox = pg.ViewBox()
|
||||||
|
item = pg.PlotItem(viewBox=viewbox, enableMenu=False)
|
||||||
|
assert item.menuEnabled() is False
|
||||||
|
viewbox = item.vb
|
||||||
|
assert viewbox is not None
|
||||||
|
assert viewbox.menu is not None
|
||||||
|
assert viewbox.menuEnabled() is True
|
||||||
|
|
||||||
|
viewbox = pg.ViewBox(enableMenu=False)
|
||||||
|
item = pg.PlotItem(viewBox=viewbox)
|
||||||
|
assert item.menuEnabled() is True
|
||||||
|
viewbox = item.vb
|
||||||
|
assert viewbox is not None
|
||||||
|
assert viewbox.menu is None
|
||||||
|
assert viewbox.menuEnabled() is False
|
||||||
|
Loading…
Reference in New Issue
Block a user