7
$\begingroup$

In an add-on I would like to have a property adjustable via its UI element, but when I have a second elements enabled I want my first element to be disabled : only show the information without being editable. It there a way to make a UI element read-only ? (grayed out / disabled / visible but un-editable).

$\endgroup$

1 Answer 1

9
$\begingroup$

Try:

col = layout.column()
col.enabled = False
# Use col.prop, col.operator, etc. Everything you add to this column will be faded

col.active is also possible, it will grey out the column but the props will still be editable (this is probably not something you want)

$\endgroup$
3
  • $\begingroup$ Actually the attribute i think I was looking for is enabled so the solution is more like col.enabled = False. Also if want only one property to be enabled/disabled I need to put just that property inside of a col/box/row UI element and then hide the col/box/row. $\endgroup$ Commented Nov 15, 2015 at 1:11
  • $\begingroup$ What about a specific item in a row? so maybe there is a randomize checkbox beside a color well. The box disabled the well. Seems only if it's on a separate row or hide it? but I want to see the randomized color in the well. $\endgroup$ Commented Nov 13, 2018 at 11:04
  • $\begingroup$ I thought this was a toggle at first (i.e. set enabled back to True after calling prop()), but you actually disable everything in the layout component or nothing at all. I had to create an extra row() to control just a single component. $\endgroup$
    – Zyl
    Commented Sep 22, 2021 at 22:03

You must log in to answer this question.

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