Can I access the "name" of a bpy.props property?

I’m not satisfied with how “use_property_split” is splitting the labels and properties in a dialog box I made. I’ve got really long labels, and I have to stretch the dialog box WIDE to get to see the complete labels, and the properties themselves take up like 60% of the width so they get really wide, but only the labels need to be really wide, not the properties themselves. So I decided to try the column.split() function so I could control how much space the label and property take up.

Not sure if this is a good idea or not (or if there is a better way), but I quickly realized I could not seem to access the “name” of the various bpy.props type properties, which I wanted for the labels (I can hard code the text, just curious if I can get at the “name” or not).

Alternatively, if there is a way to control the split factor of “use_property_split” that would be even better.

TIA

Say you have a custom property prop on the active object. You can access the value with bpy.context.active_object.prop.
However you have to access a special construct under bl_rna to get the underlying attributes of the property.

bpy.context.active_object.bl_rna.properties["prop"] will give you all the possible attributes, here for a property group :

['__doc__', '__module__', '__slots__', 'bl_rna', 'description', 'fixed_type', 'icon', 'identifier', 'is_animatable', 'is_argument_optional', 'is_enum_flag', 'is_hidden', 'is_library_editable', 'is_never_none', 'is_output', 'is_overridable', 'is_readonly', 'is_registered', 'is_registered_optional', 'is_required', 'is_runtime', 'is_skip_save', 'name', 'rna_type', 'srna', 'subtype', 'tags', 'translation_context', 'type', 'unit']

So you can use

bpy.context.active_object.bl_rna.properties["prop"].name)

1 Like

Thank you so much. I was able to tweak your solution to work for me. I was listing out properites of my AddonPreferences class in a multi-file addon. What ended up working for me was…

props = bpy.context.preferences.addons[__package__].preferences.bl_rna.properties
col1.label(text=props["some_property"].name)

I didn’t even know what “bl_rna” is really. I never would have figured that out on my own. Thanks again!!!