0
$\begingroup$

How can I hide the name of the variable related to a list box

i want the text in the red box not to be seen enter image description here

import bpy
from bpy.props import *


class MainPanel(bpy.types.Panel):
    bl_idname = "armature.retarget"
    bl_label = "Armature retarget"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = 'View'

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        layout.label(text="Select Armatures")
        layout.prop(context.scene, 'src_arm')
        layout.prop(context.scene, 'tgt_arm')
   
   
    def armatures_items(self, context):
        obs = []
        for ob in context.scene.objects:
            if ob.type == 'ARMATURE':
                obs.append((ob.name, ob.name, ""))
        return obs
    
def register():
    bpy.utils.register_class(MainPanel)

    bpy.types.Scene.src_arm = bpy.props.EnumProperty(items=MainPanel.armatures_items)
    bpy.types.Scene.tgt_arm = bpy.props.EnumProperty(items=MainPanel.armatures_items)

def unregister():
    bpy.utils.unregister_class(MainPanel)


if __name__ == "__main__":
    register()
```
$\endgroup$

1 Answer 1

1
$\begingroup$

Some options

Setting the text in the layout overrides the default

layout.prop(scene, 'tgt_arm', text="")

which by default displays the name of the property

bpy.types.Scene.tgt_arm = bpy.props.EnumProperty(
        name="Target",
        items=MainPanel.armatures_items)

which when not set defaults to the property name, in this case "tgt_arm"

Polled object pointer.

enter image description here

Would suggest instead of an enum use a pointer to the armature object itself.

As explained in https://blender.stackexchange.com/a/101301/15543 can poll them.

Example code:

import bpy
from bpy.props import *

def armature_poll(self, object):
    return object.type == 'ARMATURE'

class MainPanel(bpy.types.Panel):
    bl_idname = "armature.retarget"
    bl_label = "Armature retarget"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_category = 'View'

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        layout.prop(scene, 'tgt_arm', text="")
   
   
    def armatures_items(self, context):
        obs = []
        for ob in context.scene.objects:
            if ob.type == 'ARMATURE':
                obs.append((ob.name, ob.name, ""))
        return obs
    
def register():
    bpy.utils.register_class(MainPanel)

    bpy.types.Scene.tgt_arm = PointerProperty(
            poll=armature_poll,
            type=bpy.types.Object)

def unregister():
    bpy.utils.unregister_class(MainPanel)


if __name__ == "__main__":
    register()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .