Skip to content

Commit 412bf0a

Browse files
committed
Colormap: fix context menu entry update
1 parent ba37534 commit 412bf0a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

plotpy/tools/image.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,7 @@ class ColormapTool(CommandTool):
454454
toolbar_id: Toolbar Id to use. Defaults to DefaultToolbarID.
455455
"""
456456

457-
def __init__(
458-
self, manager: PlotManager, toolbar_id=DefaultToolbarID
459-
) -> None: # noqa: F821
457+
def __init__(self, manager: PlotManager, toolbar_id=DefaultToolbarID) -> None: # noqa: F821
460458
super().__init__(
461459
manager,
462460
_("Colormap"),
@@ -508,7 +506,6 @@ def activate_cmap(self, cmap: str | EditableColormap) -> None:
508506
param.colormap = self._active_colormap.name
509507
param.update_item(item)
510508
plot.SIG_ITEM_PARAMETERS_CHANGED.emit(item)
511-
self.action.setText(_("Colormap: %s") % self._active_colormap.name)
512509
plot.invalidate()
513510
self.update_status(plot)
514511

@@ -521,15 +518,18 @@ def update_status(self, plot: BasePlot) -> None:
521518
if update_image_tool_status(self, plot):
522519
item: BaseImageItem = plot.get_last_active_item(IColormapImageItemType)
523520
icon = self.default_icon
521+
cmap_name = "jet"
524522
if item:
525523
self.action.setEnabled(True)
526524
cmap = item.get_color_map()
527525
if cmap is not None:
528526
icon = build_icon_from_cmap_name(cmap.name)
529527
self._active_colormap = get_cmap(cmap.name)
528+
cmap_name = cmap.name
530529
else:
531530
self.action.setEnabled(False)
532531
self._active_colormap = ALL_COLORMAPS["jet"]
532+
self.action.setText(_("Colormap: %s") % cmap_name)
533533
self.action.setIcon(icon)
534534

535535

0 commit comments

Comments
 (0)