Skip to content

Commit 6ca198d

Browse files
committed
Enhance: add optional "Axes" tab control in Parameters dialog
1 parent bed5626 commit 6ca198d

File tree

3 files changed

+41
-16
lines changed

3 files changed

+41
-16
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
💥 New features / Enhancements:
66

7+
* Added optional "Axes" tab control in Parameters dialog:
8+
* New `show_axes_tab` option in `BasePlotOptions` and `PlotOptions` (default: `True`)
9+
* When set to `False`, the "Axes" tab is hidden from item parameter dialogs
10+
* This allows applications to provide their own axes management while using PlotPy
11+
* Can be configured during plot creation or changed at runtime using `plot.set_show_axes_tab(False)`
712
* [Issue #45](https://github.com/PlotPyStack/PlotPy/issues/45) - Add support for new curve Y-range cursor tool `YRangeCursorTool`:
813
* This tool is similar to the existing `CurveStatsTool`, but it simply shows the Y-range values (min, max and interval).
914
* It can be added to the plot widget using `plot_widget.manager.add_tool(YRangeCursorTool)`

plotpy/panels/itemlist.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,15 @@ def edit_plot_parameters(self) -> None:
138138
for item in sel_items:
139139
item.get_item_parameters(itemparams)
140140
sel_items[0].get_item_parameters(itemparams)
141-
Param = self.plot.get_axesparam_class(sel_items[0])
142-
axesparam = Param(
143-
title=_("Axes"),
144-
icon="lin_lin.png",
145-
comment=_("Axes associated to selected item"),
146-
)
147-
axesparam.update_param(sel_items[0])
148-
itemparams.add("AxesParam", self.plot, axesparam)
141+
if self.plot.get_show_axes_tab():
142+
Param = self.plot.get_axesparam_class(sel_items[0])
143+
axesparam = Param(
144+
title=_("Axes"),
145+
icon="lin_lin.png",
146+
comment=_("Axes associated to selected item"),
147+
)
148+
axesparam.update_param(sel_items[0])
149+
itemparams.add("AxesParam", self.plot, axesparam)
149150
# === ===
150151
title, icon = PARAMETERS_TITLE_ICON["item"]
151152
itemparams.edit(self.plot, title, icon)

plotpy/plot/base.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class BasePlotOptions:
8787
type: The plot type ("auto", "manual", "curve" or "image")
8888
axes_synchronised: If True, the axes are synchronised
8989
force_colorbar_enabled: If True, the colorbar is always enabled
90+
show_axes_tab: If True, the axes tab is shown in the parameters dialog
9091
"""
9192

9293
title: str | None = None
@@ -105,6 +106,7 @@ class BasePlotOptions:
105106
type: str | PlotType = "auto"
106107
axes_synchronised: bool = False
107108
force_colorbar_enabled: bool = False
109+
show_axes_tab: bool = True
108110

109111
def __post_init__(self) -> None:
110112
"""Check arguments"""
@@ -828,6 +830,22 @@ def set_title(self, title: str) -> None:
828830
self.setTitle(text)
829831
self.SIG_PLOT_LABELS_CHANGED.emit(self)
830832

833+
def get_show_axes_tab(self) -> bool:
834+
"""Get whether the axes tab is shown in the parameters dialog
835+
836+
Returns:
837+
bool: True if the axes tab is shown
838+
"""
839+
return self.options.show_axes_tab
840+
841+
def set_show_axes_tab(self, show: bool) -> None:
842+
"""Set whether the axes tab is shown in the parameters dialog
843+
844+
Args:
845+
show (bool): True to show the axes tab
846+
"""
847+
self.options.show_axes_tab = show
848+
831849
def get_axis_id(self, axis_name: str | int) -> int:
832850
"""Return axis ID from axis name
833851
If axis ID is passed directly, check the ID
@@ -1868,14 +1886,15 @@ def get_plot_parameters(self, key: str, itemparams: ItemParameters) -> None:
18681886
if not active_item:
18691887
return
18701888
self.get_selected_item_parameters(itemparams)
1871-
Param = self.get_axesparam_class(active_item)
1872-
axesparam = Param(
1873-
title=_("Axes"),
1874-
icon="lin_lin.png",
1875-
comment=_("Axes associated to selected item"),
1876-
)
1877-
axesparam.update_param(active_item)
1878-
itemparams.add("AxesParam", self, axesparam)
1889+
if self.get_show_axes_tab():
1890+
Param = self.get_axesparam_class(active_item)
1891+
axesparam = Param(
1892+
title=_("Axes"),
1893+
icon="lin_lin.png",
1894+
comment=_("Axes associated to selected item"),
1895+
)
1896+
axesparam.update_param(active_item)
1897+
itemparams.add("AxesParam", self, axesparam)
18791898

18801899
def set_item_parameters(self, itemparams: ItemParameters) -> None:
18811900
"""Set item (plot, here) parameters

0 commit comments

Comments
 (0)