Skip to content

Commit 5a5c53f

Browse files
authored
Merge pull request pyqtgraph#3432 from pijyoi/fix-colormapmenu
2 parents c69d8ba + e991713 commit 5a5c53f

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

doc/source/dictionaries/pyqtgraph.dic

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ Point
702702
PolyLineROI
703703
PrimitiveArray
704704
PrintDetector
705-
PrivateActionData
706705
Process
707706
Profiler
708707
ProgressBarParameter

pyqtgraph/widgets/ColorMapMenu.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import collections
21
import importlib.util
32
import re
43

@@ -38,9 +37,6 @@
3837
]
3938

4039

41-
PrivateActionData = collections.namedtuple("ColorMapMenuPrivateActionData", ["name", "source"])
42-
43-
4440
def buildMenuEntryWidget(cmap, text):
4541
lut = cmap.getLookupTable(nPts=32, alpha=True)
4642
qimg = QtGui.QImage(lut, len(lut), 1, QtGui.QImage.Format.Format_RGBA8888)
@@ -66,7 +62,7 @@ def buildMenuEntryAction(menu, name, source):
6662
else:
6763
cmap = colormap.get(name, source=source)
6864
act = QtWidgets.QWidgetAction(menu)
69-
act.setData(PrivateActionData(name, source))
65+
act.setData(ColorMapMenuActionData(name, source))
7066
act.setDefaultWidget(buildMenuEntryWidget(cmap, name))
7167
menu.addAction(act)
7268

@@ -152,7 +148,7 @@ def __init__(self, *, userList=None, showGradientSubMenu=False, showColorMapSubM
152148

153149
topmenu = self
154150
act = topmenu.addAction('None')
155-
act.setData(PrivateActionData(None, None))
151+
act.setData(ColorMapMenuActionData(None, None))
156152

157153
if userList is not None:
158154
buildUserSubMenu(topmenu, userList)
@@ -207,9 +203,9 @@ def __init__(self, *, userList=None, showGradientSubMenu=False, showColorMapSubM
207203

208204
@QtCore.Slot(QtGui.QAction)
209205
def onTriggered(self, action):
210-
if not isinstance(data := action.data(), PrivateActionData):
206+
if not isinstance(data := action.data(), ColorMapMenuActionData):
211207
return
212-
cmap = self.actionDataToColorMap(data)
208+
cmap = data.toColorMap()
213209
self.sigColorMapTriggered.emit(cmap)
214210

215211
@QtCore.Slot()
@@ -283,9 +279,13 @@ def buildSubMenu(self, names, source, sort=True):
283279
for name in names:
284280
buildMenuEntryAction(menu, name, source)
285281

286-
@staticmethod
287-
def actionDataToColorMap(data):
288-
name, source = data
282+
283+
class ColorMapMenuActionData:
284+
def __init__(self, *args):
285+
self.args = args
286+
287+
def toColorMap(self):
288+
name, source = self.args
289289
if isinstance(source, colormap.ColorMap):
290290
cmap = source
291291
elif name is None:

0 commit comments

Comments
 (0)