display_selection_streaming#
- penzai.treescope.selection_rendering.display_selection_streaming(selection: selectors.Selection, visible_selection: bool = True, ignore_exceptions: bool = False)[source]#
Displays a top-level selection object in IPython.
This function produces a rendering of either the selection itself, or its selected value. However, instead of directly outputting the attributes of the selection, we draw the selected regions as highlighted boxes around selected subtrees.
The output is still a round-trippable “repr”-like output. When
visible_selection
is True, copying it will reproduce the original selection. Whenvisible_selection
is False, copying it will reproduce the selected value.This function is used to implement
show_selection()
andshow_value()
on selection objects.- Parameters:
selection – A selection to render.
visible_selection – Whether to render the selection itself rather than the selected value. If True, renders code to build the selection itself, and highlights selected nodes in blue. If False, renders the value but expands the selected nodes.
ignore_exceptions – Whether to catch errors during rendering of subtrees and show a fallback for those subtrees, instead of failing the entire renderer. Best used in contexts where
render_selection_to_html
is not being called directly, e.g. when registering this as a default pretty-printer.