I'm trying to create a simple panel that is organazied in the following way:

  1. Properties of the main panel (text, operators, etc).
  2. Subpanel that has it's own properties and operators.
  3. More properties in the main panel.

However, I can't get it to work the way I like. See attached code. The layout is correct except that the "Plane" button is in it's own sub-panel (becuse I give it a parent_id). I want the Plane button to be in the main panel, no dropdown into a subpanel.

Example code:

import bpy

class EXAMPLE_panel:
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = "Example Tab"
    bl_options = {"DEFAULT_CLOSED"}

class EXAMPLE_PT_panel_1(EXAMPLE_panel, bpy.types.Panel):
    bl_idname = "EXAMPLE_PT_panel_1"
    bl_label = "Main"

    def draw(self, context):
        column = self.layout.column(align = True)
        column.operator("mesh.primitive_cube_add", text = "Cube")

class EXAMPLE_PT_panel_2(EXAMPLE_panel, bpy.types.Panel):
    bl_parent_id = "EXAMPLE_PT_panel_1"
    bl_label = "Subpanel"

    def draw(self, context):
        layout = self.layout
        layout.label(text="Here there will be more stuff")

class EXAMPLE_PT_panel_3(EXAMPLE_panel, bpy.types.Panel):
    bl_parent_id = "EXAMPLE_PT_panel_1"
    bl_label = "(should not exist)"

    def draw(self, context):
        column = self.layout.column(align = True)
        column.operator("mesh.primitive_plane_add", text = "Plane") 
classes = (EXAMPLE_PT_panel_1, EXAMPLE_PT_panel_2, EXAMPLE_PT_panel_3)

def register():
    for cls in classes:

def unregister():
    for cls in classes:

if __name__ == "__main__":



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.