Skip to content

Houdini - Python Panel Hello World

Create python libs directory

If the directory pythonx.ylibs is not found in the Houdini HOUDINI_USER_PREF_DIR directory, create it.

HOUDINI_USER_PREF_DIR -> The directory to store user preference files. The value of this variable must include the substring __HVER__, which will be replaced at run time with the current MAJOR.MINOR version string. On Windows and Linux, this defaults to the expanded value of $HOME/houdini__HVER__. On Mac OSX, it will also use this default if the directory exists, else it uses the expanded value of $HOME/Library/Preferences/houdini/__HVER__.

  • HOUDINI_USER_DIR - $HOME/houdini20.5
  • HOUDINI_USER_PREF_DIR - $HOME/Documents/houdini20.5

Where the default user preferences directory on Windows for example C:\Users\teoti\OneDrive\Documents\houdini20.5.

  1. Create C:\Users\teoti\OneDrive\Documents\houdini20.5\[pythonx.ylibs], e.g. python3.11libs (this version of python in your Houdini install, if the directory does not exist).

See

Create the python module directory

  1. Create C:\Users\teoti\OneDrive\Documents\houdini20.5\pythonx.ylibs\helloworld

Where helloworld directory is the new module name.

Open an IDE or Code eidtor

You can use any text editor but PyCharm and VSCode work with the previous setup instructions.

PyCharm

VSCode

Create two stub py files for later

  1. In the directory C:\Users\teoti\OneDrive\Documents\houdini20.5\pythonx.ylibs\helloworld, create:

    Where x is major version and y is minor version.

    • __init__.py
    • helloworld.py
    • Directory$HOUDINI_USER_PREF_DIR/houdini[X.Y]/
      • Directorypresets/
      • Directorypython_panels/
      • Directorypython[x.y]libs/
        • Directoryhelloworld
          • __init__.py
          • helloworld.py
      • DirectoryQtWebEngine/

Leave these files empty for now, we will get back to them.

Create the Python Panel

Houdini new python pane interface dialog.
  1. Open Houdini.
  2. Select Windows -> Python Panel Editor.
  3. Select New Interface.
  4. Set Save To $HOUDINI_USER_PREF_DIR/houdini[X.Y]/python_panels/hello_world.pypanel.
  5. Set Name: hello_world.
    • Do not change this after Apply, houdini will loose it.
  6. Set Label : Hello World.
    • Shows up in the menus by Right clicking a Pane Tab.
  7. Check the Include in Pane Tab Menu, leaving the other values at default.
  8. Click Apply.

The hello_world.pypanel file has now been created in your $HOUDINI_USER_PREF_DIR/houdini[X.Y]/python_panels/ directory.

The final directory layout;

  • Directory$HOUDINI_USER_PREF_DIR/houdini[X.Y]/
    • Directorypresets/
    • Directorypython_panels/
      • hello_world.pypanel
    • Directorypython[x.y]libs/
      • Directoryhelloworld
        • __init__.py
        • helloworld.py
    • DirectoryQtWebEngine/

Houdini bootstrap Pane creation code

  1. Add the simple bootstrap code below for the Python Pane creation.

    import imp
    from helloworld import helloworld
    imp.reload(helloworld)
    def onCreateInterface():
    widget = helloworld.createInterfaceRoot()
    return widget
  2. Click Accept and now close Houdini so it can reload and parse the new helloworld module we created.

Module bootstrap Code

Now we will create a simple QPushButton from the QtWidgets namespace of PySide2 ui framework.

The way the root pane layout manager works is it will stretch this button to full width and height extents. Normally in a panel you will create a layout container to hold this button or other UI components, for example the QHBoxLayout.

  1. No code in the __init__.py today.

    __init__.py
    # TODO
  2. Add the code below to the helloworld.py module file.

    helloworld.py
    import hou
    from PySide2.QtWidgets import QPushButton
    def createInterfaceRoot():
    widget = QPushButton("Panic!")
    widget.clicked.connect(say_hello)
    return widget
    def say_hello():
    print("Don't Panic, Hello 42!")

See Also

Test the new PythonPanel

  1. Re-Open Houdini.
  2. Select Windows -> New Floating Panel. (Alt-Shift-W)
  3. Right Click on the Floating Panel’s Pane tab and select Hello World.
  4. Click the QPushButton Panic!.
Houdini python pane execution result.

The Houdini Console should popup and print “Don’t Panic, Hello 42!”.

Success Congratulations, you just created your first Python Panel in Houdini.

See Also

Author: Michael Schmalle - teotigraphix
Date Published: 03-17-2025