pysnt.display package#
PySNT Display Module
Provides unified display functionality for SNT objects, matplotlib figures, xarray datasets, pandas DataFrames, and other data structures.
This module is organized into submodules: - core: Main display orchestration and SNT object handling - visual_display: Matplotlib figures, graphs, and visualizations - data_display: xarray datasets, pandas DataFrames, and structured data - utils: Shared utilities and helper functions
- The main display function is available directly:
from pysnt.display import display
- display(obj: Any, show: bool = True, **kwargs) Any[source]#
Display any supported object type in the most appropriate way.
Handles Java objects, SNT objects, matplotlib figures, xarray objects, Viewer2D/3D objects, and lists. Automatically converts Java objects and creates multi-panel displays for lists.
- Parameters:
obj (Any) – Object to display (Java objects, SNTObjects, matplotlib figures, xarray objects, Viewer2D/3D objects, lists, etc.)
show (bool, default True) – Whether to display the figure immediately. If False, creates the figure but doesn’t show it (useful for chaining: fig1 = pysnt.display(obj, show=False))
**kwargs – Display arguments including: - cmap: str, colormap for grayscale images - title: str, display title - figsize: tuple, figure size - orthoview: bool, for 3D viewers - panel_layout: str, layout for multi-panel displays - max_panels: int, maximum panels to display - origin: str, origin for image display (‘upper’, ‘lower’, ‘auto’)
- Returns:
Return value depends on input type
- Return type:
Any
- register_display_handler(obj_type: str, handler_func)[source]#
Register a custom display handler for a specific SNT object type.
This function allows users to register custom display handlers for specific SNT object types. When an object of the registered type is displayed, the custom handler will be called instead of the default display logic.
- Parameters:
obj_type (str) – The SNT object type identifier (e.g., ‘SNT_Tree’, ‘SNT_Path’)
handler_func (Callable[[Dict[str, Any]], None]) – Function that takes an SNTObject dictionary and displays it
Examples
>>> def display_my_object(snt_dict): ... print(f"My object: {snt_dict.get('name')}") >>> >>> register_display_handler('SNT_MyObject', display_my_object)