I'm new to python and pyqt5/pyqtgraph. Trying to add an action/item to the context menu of a PlotWidget using the code below. The New_Item appears overlaid on top of the "View All" item in the context menu (see picture) instead of above it. I'd appreciate guidance with fixing this problem. Thanks in advance for the help!
from PyQt5 import QtWidgets
import pyqtgraph as pg
class Plot(pg.PlotWidget):
def contextMenuEvent(self, event):
menu = QtWidgets.QMenu(self)
someAction = menu.addAction('New_Item')
res = menu.exec_(event.globalPos())
if res == someAction:
print('Hello')
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
plot = Plot()
plot.show()
sys.exit(app.exec_())