I'd like to update the label of an operator when it's called. But this :

def execute(self,context):
    self.bl_label = "good night"

... apparently doesn't work if the bl_label property has already been defined. Am I wrong ?


Manipulating an operator type once registered isn't supported. *

Your options are:

  • override the label when drawing the interface. eg:
    layout.operator("some.op", text=label_override)
  • Modify the class, then re-register the operator
    (unregister() & register())

Hint, if you want to do a conditional override, Python can do this by passing a dictionary...

keyword_args = {}
if some_test:
    keyword_args["text"] = label_override
layout.operator("some.op", **keyword_args)

* (unless you modify the memory directly, which is possible but outside the scope of Blender/Python API).

| improve this answer | |

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.