On this page |
Overview ¶
The Python Panel Editor window lets you create, edit and delete PySide2 or PyQt5 interfaces that can be displayed in Python Panel panes. The editor also lets you manage the entries in the Python Panel interfaces menu as well as the entries in the Houdini pane tab menu.
Requirements ¶
There are no requirements when building PySide2 interfaces. Houdini ships with PySide2 modules out-of-the-box.
To build interfaces with PyQt5, install the PyQt5 modules on your system. Houdini does its best to find the PyQt5 modules automatically however, if the modules cannot be found then add the installed location to the Python search path.
For example, if PyQt5 is installed at /path/to/site-packages/PyQt5
, then set PYTHONPATH=/path/to/site-packages
in your environment before starting Houdini. Alternatively, append /path/to/site-packages
to the search path through Python code like so:
# Modify search path import sys sys.path.append("/path/to/site-packages") # Now you can import PyQt5 from PyQt5 import QtWidgets
New to Houdini 17.0 ¶
-
Houdini 17.0 only supports Python Panels built with PySide2 or PyQt5. PySide and PyQt4 are no longer supported.
-
You can specify the placement of your interface in the pane tab type menu using the new PaneTabTypeMenu.xml file. See the Pane tab type menu section for details.
Creating and Editing Interfaces ¶
-
Open the Python Panel Editor from the Windows menu or from the toolbar button in a Python Panel pane tab.
-
To create a new interface definition, choose the Interfaces tab and click the New Interface button. The interface will be loaded in the editor and added to the menu list.
-
To edit an existing interface, select the interface from the drop down menu on the Interfaces tab.
-
Edit the name, label, icon using the interface editor.
-
Write Python code in the script text area which builds the interface. An
onCreateInterface()
function must be defined which returns the root widget of your interface. The returned root widget is embedded in the Python Panel. -
Save changes by pressing the Accept or Apply button.
Editing the Interface Menu ¶
Deleting Interfaces ¶
-
Open the Delete Interfaces dialog from the Python Panel Editor or from the toolbar button in a Python Panel pane tab.
-
In the dialog, select the interfaces to delete from the list. Multiple interfaces can be selected by holding the ⌃ Ctrl key during selection.
-
Press the Delete button to the delete the selected entries. A confirmation dialog will display before entries are deleted.
Warning
The deletion process is irreversible since interface definitions are also deleted from disk. To remove entries from the interface menu without deleting the definitions, please refer to the Editing the Interface Menu section above.
Interfaces tab ¶
The interfaces tab is used to create and edit Python interfaces. The drop down menu at the top can be used to select which interface to edit. New Interface creates a new interface and loads it into the editor. Delete Interface displays a dialog with a list of all interfaces that can be deleted.
Save To
The file path that the interface definition is saved to. The file must be writeable by Houdini for changes to be saved correctly. If the path is not writeable then an error message is displayed when attempting to apply changes to the interface. The file path can be typed manually or selected using the file browser on the right of the field.
Name
The internal name of the interface. This must be unique across all loaded Python interfaces. That is, at most one interface is loaded into for a given internal name. The name must start with a letter and can contain letters, numbers, and/or underscores.
Label
The human-readable name of the interface. The label is used in the Python Panel pane tab and in the menu interfaces menu. Multiple interfaces may share the same Label.
Icon
Internal name, file path, or URL of the icon to use for the interface.
Click the chooser button at the right end of the field to choose a file.
Note that you can choose a file contained in a digital asset (click
opdef:
on the left side of the file chooser).
If you don’t supply an absolute path or URL, Houdini will look for the
icon using the path in the $HOUDINI_UI_ICON_PATH
environment variable.
You can use an SVG file or any image format Houdini supports (such
as PNG or .pic
). The icon image should be square.
Houdini ships with a number of stock SVG icons. You can see bitmap
representations of these icons in $HFS/houdini/help/icons/large
. To specify a
stock icon, use the form ‹dirname›_‹filename›
, where…
-
‹dirname› is the directory name under
$HFS/houdini/help/icons/large
, such asOBJ
,SHELF
, orMISC
, and -
‹filename› is the icon’s filename minus any extension. For example,
OBJ_sticky
specifies the standard icon for the Sticky object.
Parameters Pane Hints
Show in Parameters Pane
Check this option to show the interface in the Parameters pane. The interface takes the place of the regular parameters dialog.
For Operators
A comma-separated list of node operator types. The interface will be shown in the Parameters pane for any node whose operator type matches any type in the list.
You can specify an operator type pattern and use wildcards to match multiple operator types.
Examples:
-
Sop/null
matches Null SOP nodes. -
Sop/*
matches all SOP nodes. -
Sop/*, Object/null
matches all SOP nodes and Null OBJ nodes.
Namespaces and version tags can also be specified in the operator type pattern.
For example:
-
namespaceX::Sop/null::2.0
matches version 2.0 of the custom Null SOP defined in the “namespaceX” namespace.
Note
The parameters dialog embedded in the Network View pane is also affected by the Parameters Pane Hints parameters.
Script
The script definition for the Python interface. This is where PySide2 or
PyQt5 code is written to build the interface. When the interface is loaded
in a Python Panel, the script is executed and the root widget returned by
the onCreateInterface()
function is embedded into the panel.
Python Panels recognize and execute the following functions when certain events occur:
-
onCreateInterface()
→PySide2.QWidget or PyQt5.QWidget
Executed when the Python Panel creates the Qt interface. The function must return the root Qt widget of the interface.
-
onDestroyInterface()
Executed when the Python Panel is about to destroy the Qt interface. This can happen when the Python Panel pane tab is closed or if the interface is reloaded.
-
onActivateInterface()
Executed when the interface becomes active and visible.
-
onDeactivateInterface()
Executed when the interface becomes inactive and hidden.
-
onHipFileBeforeClear()
Executed before the hip file clear operation is performed.
-
onHipFileAfterClear()
Executed after the hip file clear operation is performed.
-
onHipFileBeforeLoad()
Executed before the hip file load operation is performed.
-
onHipFileAfterLoad()
Executed after the hip file load operation is performed.
-
onHipFileBeforeMerge()
Executed before the hip file merge operation is performed.
-
onHipFileAfterMerge()
Executed after the hip file merge operation is performed.
-
onHipFileBeforeSave()
Executed before the hip file save operation is performed.
-
onHipFileAfterSave()
Executed after the hip file save operation is performed.
-
onNodePathChanged(node)
Executed when Houdini has changed the current node. This function hook is useful for when your Python Panel interface is interested in following navigation around the Houdini node network.
node
is the current node and is a hou.OpNode object. If there is no current node thennode
is set toNone
.Note that this function hook is also called when the Python Panel interface is first loaded.
Only the onCreateInterface()
function is required by the interface.
The other functions are optional.
Note
In older Houdini versions, the createInterface()
function was required. This function is now deprecated and replaced by onCreateInterface()
.
Note
The kwargs dictionary is available in the interface script. The dictionary contains the following entries:
-
paneTab - The pane tab (hou.PaneTab) that contains the interface. It is recommended that the result of
kwargs["paneTab"]
not be stored in a persistent variable because the hou.PaneTab object may not be valid later on. For example, switching to another pane tab type and then back to the Python Panel can cause the old pane tab object to be deleted and a new one created. Instead, always callkwargs["paneTab"]
when you need to access the pane tab.
Here is an example of using kwargs in the script:
from PySide2 import QtWidgets def onCreateInterface(): panetab = kwargs["paneTab"] label = QtWidgets.QLabel() label.setText("Running in pane tab '%s'" % panetab.name()) return label
Menu tab ¶
Pane tab type menu ¶
Python Panel files ¶
Python Panel menu and interface definitions are stored in .pypanel
files on disk.
When Houdini starts up, it searches for .pypanel
files in $HFS/houdini/python_panels
and then in $HOUDINI_USER_PREF_DIR/python_panels
by default and loads the definitions stored in those files.
If $HOUDINI_PATH
is set, then Houdini instead searches for files in the python_panels
subdirectory for each path listed in $HOUDINI_PATH
.
You can override the search path by setting $HOUDINI_PYTHON_PANEL_PATH
.
Note
Houdini loads .pypanel
files in the order of the directories specified by
$HOUDINI_PYTHON_PANEL_PATH
and then in alphabetical order by filename.
If multiple Python Panel interfaces with the same internal name are found on disk, then Houdini uses the last interface definition that it loaded.
Similarly, Houdini uses the last interfaces menu definition that it loaded.
Examples ¶
Example name | |
---|---|
Linked Parameters | Load |
This example demonstrates how to link PySide2 parameter widgets (i.e. text fields and sliders) to Houdini node parameters and vice versa. |
|
Drag and Drop | Load |
This example demonstrates how to respond to drag and drop events from Houdini. |
|
Custom Graphics Scene | Load |
This example demonstrates how to use a custom GraphicsScene subclass in a Python panel to make OpenGL calls. |
|
Qt Events | Load |
This example demonstrates how to handle widget events in a Python Panel. |
|
Qt Designer | Load |
This example demonstrates how to load an interface created by Qt Designer. |
|
Viewport Color Editor | Load |
This example provides a PySide2 interface for editing viewport colors. |
See also |