I need to simplify Blender UI, and I need to recode template_header_3D() from space_view3d.py

I already replaced all the UI elements succesfully, except for the mesh selection mode widget.

I tried several options:


row.operator("mesh.select_mode", text="", icon='VERTEXSEL').type = 'VERT'
row.operator("mesh.select_mode", text="", icon='EDGESEL').type = 'EDGE'
row.operator("mesh.select_mode", text="", icon='FACESEL').type = 'FACE'

But this does not higlights which selection modes are chosen


row.prop(toolsettings, "mesh_select_mode",icon='VERTEXSEL', text='',  toggle=True, icon_only=True)

This would work fine, but I cannot set the three different icons, because this is not accepted:




Here is the solution:

if obj and obj.mode == 'EDIT':
    row = layout.row(align=True)
    row.prop(toolsettings, "mesh_select_mode", icon='VERTEXSEL', text='', index=0, toggle=True)
    row.prop(toolsettings, "mesh_select_mode", icon='EDGESEL', text='', index=1, toggle=True)
    row.prop(toolsettings, "mesh_select_mode", icon='FACESEL', text='', index=2, toggle=True)

Using the index parameter it is possible to select elements of the bool vector.


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.