Skip to content

Commit 8d87c43

Browse files
committed
modified utils to be able to pass None to not select an item when creating a new window
1 parent 838fe1f commit 8d87c43

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plotpy/tests/unit/utils.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def drag_mouse(
223223

224224
def create_window(
225225
tool_class: type[ToolT],
226-
active_item_type: type[IItemType] = ICurveItemType,
226+
active_item_type: type[IItemType] | None = ICurveItemType,
227227
panels: list[type[PanelWidget]] | None = None,
228228
items: list[QwtPlotItem] | None = None,
229229
) -> tuple[PlotWindow, ToolT]:
@@ -245,8 +245,14 @@ def create_window(
245245
plot = win.manager.get_plot()
246246
for item in items:
247247
plot.set_active_item(item)
248-
last_active_item = plot.get_last_active_item(active_item_type)
249-
plot.set_active_item(last_active_item)
248+
if active_item_type is None:
249+
plot.unselect_all()
250+
last_active_item = None
251+
else:
252+
last_active_item = plot.get_last_active_item(active_item_type)
253+
if last_active_item is not None:
254+
plot.set_active_item(last_active_item)
255+
250256
if panels is not None:
251257
for panel in panels:
252258
win.manager.add_panel(panel())

0 commit comments

Comments
 (0)