-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Short description
Opening the context-menu via right-clicking adds an entry to the list returned by plotItem.vb.menu.actions(). Tbh this behaviour didn't lead to complications for me, but I don't think it should behave like this.
Code to reproduce
In REPL
import pyqtgraph as pg
p = pg.plot([1,2,3,[4,5,6])
len(p.plotItem.vb.menu.actions()) # = 4
# now right-click in plot window
len(p.plotItem.vb.menu.actions()) # = 7
# now right-click in plot window
len(p.plotItem.vb.menu.actions()) # = 8
# repeated right clicking and evaluation of len(...) shows always + 1Expected behavior
After first right-click, the actions-list should be constant (at 7 in this case).
Tested environment(s)
- PyQtGraph version: 0.12.4
- Qt Python binding: PyQt6 6.3.0 Qt 6.3.0
- Python version: 3.9.2
Additional context
It might be due to what GraphicsScene.addParentContextMenus is doing:
pyqtgraph/pyqtgraph/GraphicsScene/GraphicsScene.py
Lines 492 to 506 in e0b3a30
| menusToAdd = [] | |
| while item is not self: | |
| item = item.parentItem() | |
| if item is None: | |
| item = self | |
| if not hasattr(item, "getContextMenus"): | |
| continue | |
| subMenus = item.getContextMenus(event) or [] | |
| if isinstance(subMenus, list): ## so that some items (like FlowchartViewBox) can return multiple menus | |
| menusToAdd.extend(subMenus) | |
| else: | |
| menusToAdd.append(subMenus) | |
| if menusToAdd: | |
| menu.addSeparator() |
where it looks like it might in this case always call addSeparator. I'm not entirely sure, though.
BTW: the reason I came to this was, because I wanted to remove some of the entries of the contextmenu, as they don't work with the data I am plotting (different points have different brushes which clashes with some plot options).
Cheers
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels