Isotropix Forums

Manipulating widgets in Python

Find useful scripts shared by the community here

Manipulating widgets in Python

Unread postby anemoff » Wed Mar 11, 2020 4:31 pm

Hi all,

Here I'll post a couple of script examples to manipulate Clarisse widgets in Python.

To start, I'll show how to get widgets of specific types and how to pause/resume widgets that support it, like the Image View.

python code

def get_all_widgets(class_name):
Get all the widget instances for the given widget OfClass name.
For example: "WidgetImageView".

An array of OfObjects.

widgets = ix.api.OfObjectArray()
ix.application.get_factory().get_all_objects(class_name, widgets)
return widgets

def get_all_image_views():
"""Shortcut method to get all Image View widgets."""
return get_all_widgets('WidgetImageView')

def get_all_3d_views():
"""Shortcut method to get all 3d View widgets."""
return get_all_widgets('Widget3dView')

def get_all_texture_views():
"""Shortcut method to get all Texture View widgets."""
return get_all_widgets('WidgetTextureView')

def get_all_pausable_widgets():
"""Shortcut to get all pausable widgets."""
all = ix.api.OfObjectArray()
return all

def pause_widget(object, is_paused):
Pauses or resumes the given widget.

object: OfObject
> Widget's OfObject, for example retrieved using `get_all_widgets` or `ix.get_item`.

is_paused: boolean
> Use true to pause, use False to resume.

if (object.is_kindof('WidgetImageView')
or object.is_kindof('Widget3dView')
or object.is_kindof('WidgetTextureView')):
# True: auto-evaluate ON (play), False: auto-evaluate OFF (pause)
object.get_module().auto_evaluation(not is_paused)
ix.log_warning('Widget {} does not support pause/resume.'.format(object))

def pause_all_widgets(is_paused):
Pauses all pausable widgets (Image View, 3D View, Texture View).

is_paused: boolean
> Use true to pause, use False to resume.

for widget in get_all_pausable_widgets():
pause_widget(widget, is_paused)

# Pause

# Resume

More examples to come later.

Anthony Nemoff
R&D Engineer
User avatar
Posts: 281
Joined: Wed Jan 13, 2016 10:10 am

Return to Useful Community Scripts