Lock the Edit button of a custom property

Hi, i would like to know if it is possible to have a custom property showing in the UI and at the same time locking it so that the user cannot modify it through the UI. (i.e.: disabling the “Edit” button).

I can always fallback to creating a property that does not show in the UI, but i would really like to have this feature.


which UI are you talking about, a custom panel? or the built in custom properties panel? if it’s a custom panel, you can disable part of a layout, which will make it appear to be locked/greyed out.


def draw(self, context):
    row = self.layout.row()
    row.enabled = False
    row.prop(context.active_object, "my_custom_property", text="This is locked")

Actually i was thinking about a custom property yes.
But how do you access the UI of the custom property newly created and its layout??

i still don’t understand your question- custom properties do not have layouts, there is nothing to access. If you’re interested in understanding more about how the properties panel is built (which may give you some insights into whatever it is you’re trying to achieve), check out rna_prop_ui.py that ships with Blender

Hi, my question is very simple: How do you access Blender 's current GUI and more specifically the Object Properties panel and the custom properties the user adds, OUTSIDE an operator? How do you access for example the layout object of a custom property, OUTSIDE the draw method that the operator has?

the rna_prop_ui.py module that you are talking about only handles the data, not the visual part (the UI).


Are you talking about that ? It is located in rna_prop_ui.py

    if show_array_ui and isinstance(val[0], (int, float)):
        row.prop(rna_item, '["%s"]' % escape_identifier(key), text="")
    elif to_dict or to_list:
        row.label(text=val_draw, translate=False)
        if is_rna:
            row.prop(rna_item, key, text="")
            row.prop(rna_item, '["%s"]' % escape_identifier(key), text="")

    if use_edit:
        row = split.row(align=True)
        # Do not allow editing of overridden properties (we cannot use a poll function of the operators here
        # since they's have no access to the specific property...).
        row.enabled = not(is_lib_override and key in rna_item.id_data.override_library.reference)
        if is_rna:
            row.label(text="API Defined")
        elif is_lib_override:
            row.label(text="Library Override")
            props = row.operator("wm.properties_edit", text="Edit")
            assign_props(props, val_draw, key)
            props = row.operator("wm.properties_remove", text="", icon='REMOVE')
            assign_props(props, val_draw, key)

A custom property doesn’t inherently have a set layout. The user can define one, and Blender comes with a default layout in the custom properties sub panel, with one row for each property where the name, value, edit button, and remove button are displayed.

IMHO you are better off creating from scratch your own layout and adding it in a new sub panel rather than trying to tweak stock menus and layouts. My 2 Cents

this code you are showing here does not handle the widgets and UI elements of the layout. It only holds the data of the property.
Im afraid the name of the function is misleading because it has “ui” in the name, but it doesnt provide access to the widgets.
It seems, AFAIK that the UI is built on the fly and there is no “root widget” to iterate from to access all the children and the parent UILayout element of a custom property nor any other UI element. That was my first question, and still is.
If you take a look at the code you will see you dont have access to the layout outside the panel.

Regarding your last sentence. Yes, i agree, in fact that’s what i ended up doing.