I have created a set of menu entries which all use the same operator, but with different operator parameters:
As it is now all menu entries show the same tool tip. But i need to add different tool tips here so users can be better informed about what the different entries do. The only idea i have so far is to create a unique operator for each menu entry. But how can i do this dynamically?
Or is there a better solution to get different tool tips for each of the menu entries?
Here are the menu and operator that i use (simplified):
class MyAddMenu(bpy.types.Menu):
bl_label = "MyMenu"
bl_idname = "OBJECT_MT_my_add_menu"
def draw(self, context):
lo = self.layout
op = MyAddItem.bl_idname
ps = get_p_list_from_somewhere()
for p in ps:
text = "entry-%s" % p
lo.operator(op, text=text, icon='OUTLINER_OB_ARMATURE').p=p
class MyAddItem(bpy.types.Operator):
bl_idname = "OBJECT_MT_my_add_item"
bl_label = "Add Item"
bl_description ="The operator Tool Tip"
bl_options = {'REGISTER', 'UNDO'}
p = StringProperty()
def execute(self, context):
# Do something
return {'FINISHED'}
bpy.types.OBJECT_OT_lamp_add.bl_rna.properties['type']
enum. (layout.operator_enum) Or depending on the list, set up your own dynamic enum property, display with layout.prop_menu_enum, and call the op via the enum's update method. $\endgroup$