Widget
The <a href="../api/clara.viz.widgets.html#clara.viz.widgets.Widget">clara.viz.widgets.Widget</a>
translates user input, like mouse movement, into changes of camera or view properties. It also consumes the video stream produced by the renderer and displays it.
The widget can either be crated with a Renderer or a DataDefinition object. The render settings and the properties of the video stream are exposed as well.
from clara.viz.core import Renderer, DataDefinition
from clara.viz.widgets import Widget
# create and display the Widget providing a renderer
renderer = Renderer(numpy_array)
display(Widget(renderer=renderer))
# create and display the Widget providing a DataDefinition
data_definition = DataDefinition("filenam.nii.gz")
display(Widget(data_definition=data_definition))
# the video stream settings can be changed on the fly
widget = Widget(data_definition=data_definition)
display(widget)
widget.width = 1920
widget.height = 1024
# when changing render settings call `set_settings` to activate them, with that settings can be changed in batches
# switch to slice view, default is cinematic rendering
widget.settings['Views'][0]['cameraName'] = 'Top'
widget.settings['Views'][0]['mode'] = 'SLICE_SEGMENTATION'
# make live
widget.set_settings()