I want to have a pyNode with some buttons on it that modify the node. Similar to how some of the built-in nodes work (Color Ramp, Curves, etc).

I can easily put a button on the node using an operator, but the operator doesn't seem to have any way of knowing which node actually called it? Clicking a button on a node doesn't select or make active that node and all I seem to have to work with is context and event?

So, is this possible using pyNodes? Is there a way to make a button without creating an operator? I couldn't see how that would be done either.


1 Answer 1


It's possible, but you need to set a property or two on your operator so that it can find the value. Eg:

class MyOperator(bpy.types.Operator):
    tree: bpy.props.StringProperty()
    node: bpy.props.StringProperty()

Then where ever you draw it, set those properties. Eg:

def draw_buttons(self, context, layout):
    op = layout.operator("myoperator.operator")
    op.tree = self.id_data.name
    op.node = self.name

You can then use those values in the operator to find out where it was called from.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .