Python event for node selection / flag toggle?

   403   4   0
User Avatar
Member
444 posts
Joined: 8月 2019
Offline
I'm working on a custom Python panel. It needs to know when the user selects a node or toggles the display flag in the Network Editor. How could I do that? Are there events for these cases that I can listen to?
User Avatar
Member
201 posts
Joined: 1月 2013
Offline
This can be done with addEventCallback by specifying the appropriate hou.nodeEventType. But this callback will only work with a specific node type not with any.

https://www.sidefx.com/docs/houdini/hom/hou/OpNode.html#addEventCallback [www.sidefx.com]
User Avatar
Member
696 posts
Joined: 3月 2009
Offline
Yeah, I was doing something similar, you just have to make sure you use the most appropriate event handler:

def your_function(node, event_type, **kwargs):
    print(kwargs) # just to check function is being called
    hou.ui.displayMessage(f"Node {node.name()} has been changed.") 
your_node.addEventCallback((hou.nodeEventType.AppearanceChanged, hou.nodeEventType.FlagChanged), your_function)
Edited by rafaels - 2024年3月6日 08:48:16
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
User Avatar
Member
444 posts
Joined: 8月 2019
Offline
rafaels
Yeah, I was doing something similar, you just have to make sure you use the most appropriate event handler:

def your_function(node, event_type, **kwargs):
    print(kwargs) # just to check function is being called
    hou.ui.displayMessage(f"Node {node.name()} has been changed.") 
your_node.addEventCallback((hou.nodeEventType.AppearanceChanged, hou.nodeEventType.FlagChanged), your_function)

alexwheezy
This can be done with addEventCallback by specifying the appropriate hou.nodeEventType. But this callback will only work with a specific node type not with any.

https://www.sidefx.com/docs/houdini/hom/hou/OpNode.html#addEventCallback [www.sidefx.com]


Thanks for your answers. However, if I understand it correctly, this will just register the listener for a specific node. I'd like to register something "global", in other words, I'd like to call certain function when the user selects any node.

What I'm trying to make is a "history" panel, where the user can see a list of nodes that they selected, and jump to any one them, similar to a browser's history list.

Is it possible?
User Avatar
Member
201 posts
Joined: 1月 2013
Offline
You then have to dig deeper into the network's event handlers.

https://www.sidefx.com/docs/houdini/hom/network.html#intercepting-events-globally [www.sidefx.com]
https://www.sidefx.com/docs/houdini/hom/network.html [www.sidefx.com]
  • Quick Links