I have an addon which creates a panel with properties on Blender startup:

class OBJECT_PT_runcamera(bpy.types.Panel):
    bl_label = "Some Name"
    bl_space_type = "PROPERTIES"
    bl_region_type = "WINDOW"
    bl_context = "render"

    def draw_header(self, context):
        layout = self.layout
        layout.label(text="", icon="MESH_GRID")

    def draw(self, context):
        layout = self.layout
        row1 = layout.row()
        row1.prop(context.scene, "myCustomPropertysName")

Now, after the panel has been created, I want to change the row's enabled value when user clicks some specific button -- ie, some properties (shown in rows) in the panel will be disabled/enabled by some function called from another property/button.

I've tried different ways to write the command but nothing worked.

bpy.types.Scene.show_row = bpy.props.BoolProperty()

row1.enabled = context.scene.show_row

And your other function will just set the show_row property. Thats it.

  • $\begingroup$ OK, my code now: bpy.types.Scene.show_row2 = bpy.props.BoolProperty(default=True). Then I define a function to switch enabled: def switchCustomProp(self, context): context.scene.show_row2 = False. Then the switch: bpy.types.Scene.mySwitch = bpy.props.BoolProperty(default=True, update=switchCustomProp). Then the panel is loaded where row2 gets set to some other property (myCustomProperty) and row2.enabled=context.scene.show_row2. Now, when I click the bool property in row1, row2 does not get enabled/disabled :/ $\endgroup$
    – Val
    Jan 29 '15 at 9:58
  • $\begingroup$ Ah, I had one extra row2.enabled=True inside the panel's code which overwrote the row2.enabled=context.scene.show_row2. Deleted it and it works now. THX! $\endgroup$
    – Val
    Jan 29 '15 at 10:29

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.