1
$\begingroup$

Blender 2.92x

I want to make an N pie menu panel for The Shader Editor.

By the way, what is up with the label miss-match.

The menu reads the Shader Editor, but in BPY the term is NODE_EDITOR.

class TestPanel(bpy.types.Panel):
    bl_label = "Nodes"
    bl_idname = "PT_TestPanel"
    bl_space_type = 'NODE_EDITOR'
    bl_region_type = 'UI'
    bl_category = 'Nodes'
$\endgroup$
5
  • $\begingroup$ Shader Editor is a NODE_EDITOR set to work with ShaderNodeTrees. If your panel is to show only in the Shader Editor, then you need to do that check in the poll function (context.space_data.tree_type == 'ShaderNodeTree'). $\endgroup$
    – Secrop
    Commented May 25, 2021 at 21:31
  • $\begingroup$ Wow really, So what is the point of "bl_space_type"" my script will make a N panel in 3D View if it's set like bl_space_type = 'VIEW_3D' The API Manual said bl_space_type is "NODE_EDITOR" I would think that all panels would work in any Pain with a N panel $\endgroup$
    – Sam Hanks
    Commented May 25, 2021 at 21:50
  • 2
    $\begingroup$ Your panels are registered to a specific space (no big changes in the API), the difference is that in new versions of blender, the entries in the menu are splitted into different contexts (all types of node systems, uv and image), thought the editores are of the same space_type. Your panel, for example might not be needed for geometry_nodes, but you still have to register it to the Node_Editor, which alone will show in all node types areas. Btw, bl_category is the name in the tab, bl_label will be the title of your panel. $\endgroup$
    – Secrop
    Commented May 26, 2021 at 0:17
  • $\begingroup$ Secrop, thanks for the education, It's a lot to take in I've much to learn. Can't find a Shader Editor N Panel script example to study. Thanks again for your Skill and Time. $\endgroup$
    – Sam Hanks
    Commented May 26, 2021 at 15:23
  • $\begingroup$ Is it not working for you? (well i assume that your panel is then all the code that you posted!). $\endgroup$
    – Secrop
    Commented May 26, 2021 at 22:02

1 Answer 1

2
$\begingroup$

If your Panel's code is just what you posted, then you're missing some parts of a Panel's requirements.

Here's a small template for 'Shader Editor' to mess around:

import bpy

class SuperSimplePanel(bpy.types.Panel):
    bl_label = "The label of this panel"
    bl_idname = "NODE_PT_ThisSimplePanel" # This is new
    bl_space_type = 'NODE_EDITOR'         # This tells where to show
    bl_region_type = 'UI'
    bl_category = 'OH ANOTHER TAB'     # if it doesn't exist, it will be created

    @classmethod
    def poll(cls, context):         # This tells when to show
        return (context.space_data.type == 'NODE_EDITOR' and
                context.space_data.tree_type == 'ShaderNodeTree')

    def draw(self, context):       # This tells what to show
        layout = self.layout
        layout.label("I'm a label in a Panel")
        

def register():
    bpy.utils.register_class(SuperSimplePanel)


def unregister():
    bpy.utils.unregister_class(SuperSimplePanel)


if __name__ == "__main__":
    register()
```
$\endgroup$
1
  • $\begingroup$ Secrop, That was very kind of you to provide this code as well the comments. You can be sure it will teach me much and I will get many lessons from your generosity. $\endgroup$
    – Sam Hanks
    Commented May 27, 2021 at 15:30

You must log in to answer this question.

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