# Why isn't a button added in the panel by running this script?

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():
bpy.utils.register_module(__name__)

def unregister():
bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
register()

print("my stuff loaded")


## 1 Answer

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
myOperator.action='TOGGLE'

• added some more info to your answer, hope you don't mind – aliasguru Dec 4 '16 at 14:13
• @aliasguru Thanks, I didn't even think of that! – JakeD Dec 4 '16 at 14:26