Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when adding items to histogram menu in 0.13.4 #2959

Closed
samtygier-stfc opened this issue Mar 14, 2024 · 3 comments
Closed

TypeError when adding items to histogram menu in 0.13.4 #2959

samtygier-stfc opened this issue Mar 14, 2024 · 3 comments

Comments

@samtygier-stfc
Copy link

Short description

In 0.13.3 I was able to add additional items to the menu of the histogram gradient. The changes in 0.13.4 mean that this now gives a TypeError

  File ".../pyqtgraph/graphicsItems/GradientEditorItem.py", line 499, in contextMenuClicked
    name, source = action.data()
TypeError: cannot unpack non-iterable NoneType objec

Code to reproduce

import pyqtgraph as pg
import numpy as np
from pyqtgraph.Qt import QtWidgets

app = pg.mkQApp("ImageView Example")
win = QtWidgets.QMainWindow()
img = pg.ImageView()
img.setImage(np.zeros((100,100)))
win.setCentralWidget(img)

action = QtWidgets.QAction("Test")
action.triggered.connect(lambda :print("Action triggered"))
menu = img.getHistogramWidget().gradient.menu
menu.addAction(action)

win.show()
if __name__ == '__main__':
    pg.exec()

Expected behavior

Add a new menu entry that can be used. (works in 0.13..3)

Real behavior

Menu item works, but gives the above error message

Tested environment(s)

  • PyQtGraph version: 0.13.4
  • Qt Python binding: PyQt5 5.15.9 Qt 5.15.8'
  • Python version: 3.10.13
  • NumPy version: 1.21.6
  • Operating system: Linux
  • Installation method: conda

Additional context

I think this was introduced by
#2779
c2372a2

The menu items in the GradientEditorItem are now expected to have data, that is used to change the gradient:

name, source = action.data()

I can provide a patch

@pijyoi
Copy link
Contributor

pijyoi commented Mar 14, 2024

Your test script works without error with the current PR #2955

@samtygier-stfc
Copy link
Author

I have just tested #2955, and it does fix this issue that we are hitting in mantidimaging

@j9ac9k
Copy link
Member

j9ac9k commented Mar 21, 2024

Thanks for testing; there's something I wanted to add to #2955 and will likely cut a pyqtgraph release after that gets added and the PR gets merged.

@j9ac9k j9ac9k closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants