Module containing user interface related functions.
Functions
curDesktop()→ hou.DesktopReturn the current desktop.
desktops()→tupleof hou.DesktopReturn all the desktops.
See hou.Desktop.setAsCurrent for an example.
addDesktop(name)This feature is not yet implemented
paneTabs(self)→tupleof hou.PaneTabReturn a tuple of all visible pane tabs, including those in all floating windows.
See also hou.Desktop.paneTabs.
floatingPaneTabs(self)→tupleof hou.PaneTabReturn all the pane tabs in floating panels.
See also hou.Desktop.floatingPaneTabs.
paneTabOfType(self, type, index=0)→ hou.PaneTab orNoneFind 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=0to return the first found tab,index=1to return the second found tab, etc. By default, index is 0.See also hou.Desktop.paneTabOfType.
paneTabUnderMouse()→[Hom:hou.PaneTab]or NoneThis feature is not yet implemented
findPaneTab(self, name)→ hou.PaneTab or NoneReturn the pane tab with the given name, or
Noneif no such tab exists.The name may optionally be prefixed by the desktop name and a period.
See also hou.Desktop.findPaneTab.
floatingPanels(self)→tupleof hou.FloatingPanelReturn all the visible floating panels.
See also hou.Desktop.floatingPanels.
displayMessage(text, buttons=('OK',), severity=hou.severityType.Message, default_choice=0, close_choice=None, help=None, title=None, details=None, details_expanded=False)→ intPop 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.
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.Fatalwill exit Houdini after the user closes the dialog.default_choice The index of the button that is selected if the user presses enter.
close_choice The index of the button that is selected if the user presses Escape or closes the dialog.
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.
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()
readInput(message, buttons=(1,'OK'), severity=hou.severityType.Message, default_choice=0, close_choice=None, 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.Fatalwill exit Houdini after the user closes the dialog.default_choice The index of the button that is selected if the user presses enter.
close_choice The index of the button that is selected if the user presses Escape or closes the dialog.
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, close_choice=None, help=None, title=None, initial_contents=(0,))→ (int,tupleofstr)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.Fatalwill exit Houdini after the user closes the dialog.default_choice The index of the button that is selected if the user presses enter.
close_choice The index of the button that is selected if the user presses Escape or closes the dialog.
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)→strPop 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, num_visible_rows=10)→tupleofintPop 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”.num_visible_rows The number of rows of entries that are visible at a time. If there are more possible choices than visible rows, Houdini will use a scrollbar.
selectNode(relative_to_node=None, initial_node=None, node_type_filter=None)→strorNonePop 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
Noneif 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.
setStatusMessage(message, severity=hou.severityType.Message)Display a message in Houdini’s status bar.
severityA hou.severityType enum value that determines the background color of the message.
To clear the status bar, call
hou.ui.setStatusMessage("").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.
callback Any callable Python object that expects no parameters. It could be a Python function, a bound method, or any object implementing
__call__.def checkForAndProcessEvents(): # Here is where you would check for and process any events. pass hou.ui.addEventLoopCallback(checkForAndProcessEvents)
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()
If you find that your callback is being called too often, you can use this function instead of hou.ui.waitUntil to control how often Houdini invokes the callback:
import time def wait_until(callback, poll_time_in_s): '''This function is like hou.ui.waitUntil, except it waits the specified poll time before calling the callback again. ''' global _last_check_time _last_check_time = 0.0 def wrapper_callback(): global _last_check_time if time.time() < _last_check_time + poll_time_in_s: return False _last_check_time = time.time() return callback() hou.ui.waitUntil(wrapper_callback)
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()→tupleof callbackReturn a tuple of all the Python callbacks that have been registered with hou.ui.addEventLoopCallback.
processPendingEvents()This feature is not yet implemented
updateMode()→ hou.updateMode enum valueThis 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 ofstr)This feature is not yet documented
showFloatingDetailsViewWindow(node)This feature is not yet implemented
showFloatingParmWindow(node)This feature is not yet implemented
makeSureChannelEditorIsOpen()This feature is not yet implemented
isDoubleBufferOn()This feature is not yet implemented
setDoubleBuffer(on)This feature is not yet implemented
orientationUpAxis(self)→ hou.orientUpAxis enum valueReturn a hou.orientUpAxis indicating the current orientation mode’s up axis.
shellIO()→ hou.ShellIOReturn 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.
writePythonShellHistoryFile(filename=None)Save the command history from the current Python Shell to disk. If
filenameis None, then the history is written to $HOME/houdiniX.X/pyshell.history. If this function is invoked outside of a Python Shell, then the history is taken from the last active shell (i.e. the last shell that was opened or accepted input).Raises hou.OperationFailed if no Python Shell has been opened. Raises hou.OperationFailed if
filenamecannot be created.readPythonShellHistoryFile(filename=None)Load the contents from the specified file into the command history of the Python Shell. If
filenameis None, then the history is read from $HOME/houdiniX.X/pyshell.history. If this function is invoked outside of a Python Shell, then the history is loaded into the the last active shell (i.e. the last shell that was opened or accepted input).Raises hou.OperationFailed if no Python Shell has been opened. Raises hou.OperationFailed if
filenamedoes not exist or cannot be read._getTabMenuIconSize()→ (int,int)Used internally by Houdini to get the current icon size in the tab menu.
beginUploadingAssetFromNode(node, session_key)This feature is not yet documented