mitk.mxn.layout.MxNWindowSelector#

class mitk.mxn.layout.MxNWindowSelector(source, predicate=None)#

Bases: Generic[_Source]

Filter + bulk-transform over a tree’s windows.

Each filter call returns a new selector; each terminal call returns a value (read) or a new T (update). All operations are immutable.

Parameters:
__init__(source, predicate=None)#
Parameters:
Return type:

None

Methods

__init__(source[, predicate])

by_display_name(*names)

Keep only windows whose display names match any of names.

by_id(*ids)

Keep only windows whose ids match any of ids.

by_view(*view_directions)

Keep only windows in any of the supplied view directions.

ids()

link_to(link, *[, dim])

Re-link every selected window to link on dimension dim.

map(fn)

Escape hatch -- replace each selected window with fn(window).

to_list()

where(*[, view_direction, ids, ...])

Compose multiple filter predicates AND-style.

with_display_name(name)

with_view_direction(vd)

__iter__()#
Return type:

Iterator[LayoutWindow]

__len__()#
Return type:

int

by_display_name(*names)#

Keep only windows whose display names match any of names.

None matches windows that have no display label set.

Return type:

MxNWindowSelector[TypeVar(_Source, MxNLayoutDocument, Split)]

Parameters:

names (str | None)

by_id(*ids)#

Keep only windows whose ids match any of ids.

Return type:

MxNWindowSelector[TypeVar(_Source, MxNLayoutDocument, Split)]

Parameters:

ids (str)

by_view(*view_directions)#

Keep only windows in any of the supplied view directions.

Return type:

MxNWindowSelector[TypeVar(_Source, MxNLayoutDocument, Split)]

Parameters:

view_directions (ViewDirection | str)

ids()#
Return type:

list[str]

Re-link every selected window to link on dimension dim.

On a document source, materialises a default Group entry for a previously-unknown group name so strict-mode invariants hold on the returned document. On a Split source there is no group registry to update.

Return type:

TypeVar(_Source, MxNLayoutDocument, Split)

Parameters:
map(fn)#

Escape hatch – replace each selected window with fn(window).

The selector preserves no invariants beyond what MxNLayoutDocument.create enforces on construction; if the caller introduces a duplicate id, MxNLayoutDocument.validate() will catch it on the next validate() call (or implicitly via MxNLayoutDocument.create if the result is rebuilt).

Return type:

TypeVar(_Source, MxNLayoutDocument, Split)

Parameters:

fn (Callable[[LayoutWindow], LayoutWindow])

to_list()#
Return type:

list[LayoutWindow]

where(*, view_direction=None, ids=None, display_names=None, predicate=None, group=None, dim=LinkDimension.SELECTION)#

Compose multiple filter predicates AND-style.

All keyword arguments are optional; the resulting selector keeps only windows that satisfy every supplied predicate.

Return type:

MxNWindowSelector[TypeVar(_Source, MxNLayoutDocument, Split)]

Parameters:
with_display_name(name)#
Return type:

TypeVar(_Source, MxNLayoutDocument, Split)

Parameters:

name (str | None | Callable[[LayoutWindow], str | None])

with_view_direction(vd)#
Return type:

TypeVar(_Source, MxNLayoutDocument, Split)

Parameters:

vd (ViewDirection | str)