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()