Subpanels without dropdowns - possible?

I’m trying to add a panel, a subpanel and a button to a layout. Both the sub-panel and the button should have the main panel as the parent. So far, I haven’t been able to add the button without having a “dropdown” created. Is there a way to do this? I have looked around in the blender gui, but haven’t found any examples of this.

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):
        pass

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:
        bpy.utils.register_class(cls)

def unregister():
    for cls in classes:
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()
    bl_options = {'HIDE_HEADER'}

Although I’m not sure that it can be aligned to the bottom edge.

1 Like

That works great, thanks a lot! I had completely missed that option.

Let me know how this works for you, I’ve ran into some problems using header-less subpanels when expanding their parent before, especially right as Blender opens. If you don’t run into issues, great, if you do, in theory they could be fixed.

@HooglyBoogly: At first it seemd to work great, but now that I twirl open the parent, I get this error (a lot):

 Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 2.90\2.90\scripts\modules\bpy_types.py", line 808, in draw_ls
    func(self, context)
TypeError: bpy_struct.__new__(type): expected a single argument

It seems to happen every time I click anywhere in blender and have the parent open. As soon as I close the parent the error stops printing.

Any way to work around this?