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:
source (_Source)
predicate (Callable[[LayoutWindow], bool] | None)
- __init__(source, predicate=None)#
- Parameters:
source (_Source)
predicate (Callable[[LayoutWindow], bool] | None)
- 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
linkon dimensiondim.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)- __iter__()#
- Return type:
- by_display_name(*names)#
Keep only windows whose display names match any of
names.Nonematches 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)
- link_to(link, *, dim=LinkDimension.SELECTION)#
Re-link every selected window to
linkon dimensiondim.On a document source, materialises a default
Groupentry for a previously-unknown group name so strict-mode invariants hold on the returned document. On aSplitsource there is no group registry to update.- Return type:
TypeVar(_Source,MxNLayoutDocument,Split)- Parameters:
dim (LinkDimension | str)
- map(fn)#
Escape hatch – replace each selected window with
fn(window).The selector preserves no invariants beyond what
MxNLayoutDocument.createenforces on construction; if the caller introduces a duplicate id,MxNLayoutDocument.validate()will catch it on the nextvalidate()call (or implicitly viaMxNLayoutDocument.createif the result is rebuilt).- Return type:
TypeVar(_Source,MxNLayoutDocument,Split)- Parameters:
fn (Callable[[LayoutWindow], LayoutWindow])
- to_list()#
- Return type:
- 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:
view_direction (ViewDirection | str | None)
predicate (Callable[[LayoutWindow], bool] | None)
dim (LinkDimension | str)
- 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)