This script was suppose to create a tab on tools panel and add a button in it.

But after I run just the panel is added. Any directions what I am doing wrong?

import bpy
from bpy.types import Menu, Panel, UIList

class View3DPanel():
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'

class MyPoseLibraryPanel(View3DPanel, Panel):
    bl_label = "Legs"
    bl_context = "posemode"
    bl_category = "My Pose Library"

    def draw(self, context):
        layout = self.layout
        col = layout.column(align=True)
        layout.operator("bpy.ops.pose.select_all(action='TOGGLE')", text="Legs.Idle.1", icon="MOD_ARMATURE")

def register():

def unregister():

if __name__ == "__main__":

print("my stuff loaded")               

enter image description here


Line 16 should read:

layout.operator("pose.select_all", text="Legs.Idle.1", icon="MOD_ARMATURE")

You aren't giving the full path and the parameters. You are choosing an operator so Blender already knows that it is in "bpy.ops". When the user pushes the button, he will set the values.

If you want to make sure you use your own hard-coded values, make your own operator class, that calls the bpy.ops.pose.select_all() operator inside of it with desired parameters, or catch the result of the operator layout definition in a variable, and set the parameters like this:

# catch the defined operator in a variable
myOperator = layout.operator("pose.select_all", text="Legs.Idle.1", icon="MOD_ARMATURE")

# set the options on that var. Add as many as needed
| improve this answer | |
  • $\begingroup$ added some more info to your answer, hope you don't mind $\endgroup$ – aliasguru Dec 4 '16 at 14:13
  • $\begingroup$ @aliasguru Thanks, I didn't even think of that! $\endgroup$ – JakeD Dec 4 '16 at 14:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.