hou.ui module

Module containing user interface related functions.

Functions

curDesktop()hou.Desktop

Return the current desktop.

desktops()tuple of hou.Desktop

Return all the desktops.

See hou.Desktop.setAsCurrent for an example.

addDesktop(name)

Not implemented yet

paneTabs(self)tuple of hou.PaneTab

Return a tuple of all visible pane tabs, including those in all floating windows.

See also hou.Desktop.paneTabs.

floatingPaneTabs(self)tuple of hou.PaneTab

Return all the pane tabs in floating panels.

See also hou.Desktop.floatingPaneTabs.

paneTabOfType(self, type, index=0)hou.PaneTab or None

Find and return the pane tab with the desired type. If no such tab exists, return None.

type

A hou.paneTabType enumerated variable.

index

If there are multiple tabs with the desired type, this parameter determines which one is returned. Use index=0 to return the first found tab, index=1 to return the second found tab, etc. By default, index is 0.

See also hou.Desktop.paneTabOfType.

paneTabUnderMouse()[Hom:hou.PaneTab] or None

Not implemented yet

findPaneTab(self, name)hou.PaneTab or None

Return the pane tab with the given name, or None if no such tab exists.

The name may optionally be prefixed by the desktop name and a period.

See also hou.Desktop.findPaneTab.

floatingPanels(self)tuple of hou.FloatingPanel

Return all the visible floating panels.

See also hou.Desktop.floatingPanels.

displayMessage(text, buttons=('OK',), severity=hou.severityType.Message, default_choice=0, help=None, title=None, details=None, details_expanded=False) → int

Pop up a small window with a message and one or more buttons and wait for the user to press a button. Return the index of the button the user pressed.

def saveIfNeeded():
    '''Prompt the user if they want to save, and save the hip file if they choose Yes.'''
    if hou.ui.displayMessage("Save the current hip file?", buttons=("Yes", "No")) == 0:
        hou.hipFile.save()

text

The message to display.

buttons

A sequence of strings containing the names of the buttons. By default the message window contains a single OK button.

severity

A hou.severityType value that determines which icon to display on the dialog. Note that using hou.severityType.Fatal will exit Houdini after the user closes the dialog.

default_choice

The index of the button that is selected if the user presses enter.

help

Additional help information to display below the main message.

title

The window’s title. If None, the title is “Houdini”.

details

A string containing extra messages that is not visible unless the user clicks “Show Details”.

details_expanded

A boolean, if true then the text area where the detail messages appear is always shown and cannot be collapsed. If false, the detail message area is initially folded when the message box is popped up and the user can expand to read the details.

readInput(message, buttons=(1,'OK'), severity=hou.severityType.Message, default_choice=0, help=None, title=None, initial_contents=None) → (int, str)

Pop up a small window with a textbox and wait for the user to enter a line of text. Return a tuple containing an integer and the text they entered. The integer is 0 if they pressed OK and -1 if they closed the dialog by clicking its close button, or, in general, an index of the button they pressed.

message

The message to display above the text field.

buttons

A sequence of strings containing the names of the buttons. By default the message window contains a single OK button.

severity

A hou.severityType value that determines which icon to display on the dialog. Note that using hou.severityType.Fatal will exit Houdini after the user closes the dialog.

default_choice

The index of the button that is selected if the user presses enter.

help

Additional help information to display below the main message.

title

The window’s title. If None, the title is “Houdini”.

initial_contents

The initial contents of the text field. If None, the text field is initially empty.

See also hou.ui.readMultiInput

readMultiInput(message, input_labels, password_input_indices=(), buttons=(1,'OK'), severity=hou.severityType.Message, default_choice=0, help=None, title=None, initial_contents=(0,)) → (int, tuple of str)

Pop up a small window with a textbox and wait for the user to enter a text into several input fields. Return a tuple containing an integer and the tuple of strings they entered, one for each input field. The integer is 0 if they pressed OK and -1 if they closed the dialog by clicking its close button, or, in general, an index of the button they pressed.

message

The message to display above the text field.

input_labels

A sequence of labels to appear in front of each input field. The length of the sequence determines the number of input fields that will appear in the window.

password_input_indices

A sequence of indices of which input fields are password fields. Fields whose index is not in this sequence will not be password fields.

buttons

A sequence of strings containing the names of the buttons. By default the message window contains a single OK button.

severity

A hou.severityType value that determines which icon to display on the dialog. Note that using hou.severityType.Fatal will exit Houdini after the user closes the dialog.

default_choice

The index of the button that is selected if the user presses enter.

help

Additional help information to display below the main message.

title

The window’s title. If None, the title is “Houdini”.

initial_contents

The list that specifies the initial contents of each of the text field. The length of the list does not need to be the same as the number of the input fields. If it is shorter, then initially the remaining input fields will be empty.

See also hou.ui.readInput

selectFile(start_directory=None, title=None, collapse_sequences=False, file_type=hou.fileType.None, pattern=None, default_value=None, multiple_select=False, image_chooser=False, chooser_mode=hou.fileChooserMode.ReadAndWrite)str

Pop up a window with a file chooser dialog and wait for the user to choose a file name. Return the path to the file that was selected.

start_directory

The directory the dialog should initially start in.

title

The window title for the dialog.

collapse_sequences

Whether sequences of files with common numeric patterns should be collapsed into patterns containing $F.

file_type

A hou.fileType enumerated value to say what type of file to select. The set of visible files is determined by this file type and the pattern.

pattern

Only files matching this pattern (and anything restricted by the file type) will be listed. By default, everything matches the pattern.

default_value

The default contents of the file name field in the dialog.

multiple_select

Whether the user may select multiple files.

image_chooser

Whether the dialog shows image thumbnails.

chooser_mode

A hou.fileChooserMode enumeration value to say if the user is being prompted for a file to read from, write to, or either.

selectFromList(choices, default_choices=(0,), exclusive=False, message=None, title=None)tuple of int

Pop up a window with a set of choices in a list box and prompt the user to choose zero or more of them.

choices

A sequence of strings containing the possible choices.

default_choices

A sequence of integers containing the indices of the choices that are initially selected.

exclusive

Whether or not the user must choose exactly one of the possible choices.

message

The message to display above the list box.

title

The window’s title. If None, the title is “Houdini”.

selectNode(relative_to_node=None, initial_node=None, node_type_filter=None)str or None

Pop up a window with a node tree view and prompt the user to choose a node.

If the user selects a node, returns a string containing the path to the node. If the user presses clear, returns an empty string. If the user presses cancel, returns None.

relative_to_node

A hou.Node for relative paths, or None if relative paths are not supported. Passing in a node enables the Use Relative Paths checkbox.

If this parameter is supplied and the user checks the Use Relative Paths checkbox, this function returns a relative path to the node.

initial_node

The hou.Node that is initially selected.

node_type_filter

An optional hou.nodeTypeFilter enumerated value that determines which types of nodes appear in the tree view.

The following function takes a hou.Parm, prompts the user to choose a node, and sets the value of the parameter as long as the user does not click cancel.

def setParmOnNode(parm, node_type_filter=None):
    path = hou.ui.selectNode(relative_to_node=parm.node(), node_type_filter=node_type_filter)
    if path is not None:
        parm.set(path)

You might call this function as follows:

>>> setParmOnNode(hou.parm("/obj/box_object1/shop_materialpath"), hou.nodeTypeFilter.Shop)

displayNodeHelp(node_type)

Display the help for the specified node type. If no help browser is open, this function will create a new one.

If you want to display the help for a node instance, it is easy to access the hou.NodeType from the node, as illustrated in this example:

def displayHelpForNode(node):
    '''Given a hou.Node, display its help.'''
    hou.ui.displayNodeHelp(node.type())

openTypePropertiesDialog(node_or_node_type, promote_spare_parms=False, immediately_save=False)

Given a hou.Node or hou.NodeType instance, open the spare properties dialog.

promote_spare_parms

If this parameter is True and you passed in a node instance, automatically promote any spare parameters on the node into parameters on the node type.

immediately_save

When true, immediately save the current state of the node type, as if you clicked “Apply” in the type properties dialog.

addEventLoopCallback(callback)

Register a Python callback to be called whenever Houdini’s event loop is idle. This callback is called approximately every 50ms, unless Houdini is busy processing events.

def checkForAndProcessEvents():
    # Here is where you would check for and process any events.
    pass
hou.ui.addEventLoopCallback(checkForAndProcessEvents)

callback

Any callable Python object that expects no parameters. It could be a Python function, a bound method, or any object implementing __call__.

You might use this function to integrate another user interface toolkit into Houdini’s event loop. See the PyQt and wxPython cookbook examples for example usages.

waitUntil(condition_callback)

Keep calling the supplied callback until it returns True. In the meantime, Houdini will continue to be responsive, allowing you to continue to interact with it.

For example, start a blank Houdini session and put the following in a shelf tool. It will wait until you create an object node before finishing running the tool.

print "waiting until you create an object..."
hou.ui.waitUntil(lambda: len(hou.node("/obj").children()) > 0)
print "you created", hou.node("/obj").children()

removeEventLoopCallback(callback)

Remove a Python callback that was previously registered with hou.ui.addEventLoopCallback. See hou.ui.addEventLoopCallback for more information.

Raises hou.OperationFailed if the callback was not previously registered.

eventLoopCallbacks()tuple of callback

Return a tuple of all the Python callbacks that have been registered with hou.ui.addEventLoopCallback.

processPendingEvents()

Not implemented yet

updateMode()hou.updateMode enum value

This method is deprecated in favor of hou.updateModeSetting.

setUpdateMode(mode)

This method is deprecated in favor of hou.setUpdateMode.

triggerUpdate()

Force the viewports to update and perform any cooks necessary. You might call this function when Houdini’s Auto Update mode is on Manual.

displayFileDependencyDialog(rop_node=None, uploaded_files=(), forced_unselected_patterns=(), project_dir_variable='HIP', is_standalone=true) → (bool, tuple of str)

Not documented yet

showFloatingDetailsViewWindow(node)

Not implemented yet

showFloatingParmWindow(node)

Not implemented yet

makeSureChannelEditorIsOpen()

Not implemented yet

isDoubleBufferOn()

Not implemented yet

setDoubleBuffer(on)

Not implemented yet

shellIO()hou.ShellIO

Return the hou.ShellIO object used to implement Houdini’s graphical Python shell. This function is used internally by Houdini, and you shouldn’t need to access the ShellIO directly.

_getTabMenuIconSize() → (int, int)

Used internally by Houdini to get the current icon size in the tab menu.