How can I modify the layout.label in a custom node in the Node Editor?

by sameen kee   Last Updated January 14, 2019 10:15 AM

enter image description here

As you can see, I created some custom nodes, and I need to modify the middle label in each node when I create a new node, how can I do this?

Here is my source code:

import bpy
from bpy.types import NodeTree, Node, NodeSocket

class VadCustomTree(NodeTree):
    '''A vad node tree type that will show up in the node editor header'''
    bl_idname = 'VadTreeType'
    bl_label = 'Vad Node Tree'
    bl_icon = 'NODETREE'

# Vad socket type
class VadCustomSocket(NodeSocket):
    '''Vad node socket type'''
    bl_idname = 'VadSocketType'
    bl_label = 'Vad Node Socket'

    def draw(self, context, layout, node, text):

    def draw_color(self, context, node):
        return (1.0, 0.4, 0.216, 0.5)

class VadCustomTreeNode:
    def poll(cls, ntree):
        return ntree.bl_idname == 'VadTreeType'

class VadCustomNode(Node, VadCustomTreeNode):
    '''A custom node'''
    bl_idname = 'VadNodeType'
    bl_label = 'Vad Node'
    bl_icon = 'SOUND'

    def init(self, context):'VadSocketType', " ")'NodeSocketColor', " ")

    def copy(self, node):
        print("Copying from node ", node)

    def free(self):
        print("Removing node ", self, ", Goodbye!")

    def draw_buttons(self, context, layout):

    def draw_label(self):
        return "vad node"

import nodeitems_utils
from nodeitems_utils import NodeCategory, NodeItem

class VadNodeCategory(NodeCategory):
    def poll(cls, context):
        return context.space_data.tree_type == 'VadTreeType'

node_categories = [
    # identifier, label, items list
    VadNodeCategory("SOMENODES", "Some Nodes", items=[
        # our basic node

def register():

    nodeitems_utils.register_node_categories("CUSTOM_NODES", node_categories)

def unregister():


if __name__ == "__main__":
    bpy.context.scene.use_nodes = True
    tree = bpy.context.scene.node_tree

    # clear default nodes
    for node in tree.nodes:

    # create input vad node
    vad_node ='VadNodeType')
    vad_node.location = 0,0

    vad_node1 ='VadNodeType')   
    vad_node1.location = 400,0
    vad_node1.label = "lalalala" # vad node's header, not the content

    vad_node2 ='VadNodeType')
    vad_node2.location = 400,200

    links = tree.links[0], vad_node1.inputs[0])[0], vad_node2.inputs[0])

I really appreciate your answer.

Tags : python nodes

Related Questions

Updated July 29, 2018 21:15 PM

Updated April 05, 2018 14:15 PM

Updated July 23, 2018 02:15 AM

Updated April 13, 2015 02:06 AM

Updated May 03, 2015 21:06 PM