The draw function of a panel is intended only for adjusting UI, it is essentially blocked from doing anything else by design. At first this limitation can be perceived as restrictive, but it's really there to prevent bad practice and unnecessary updates. When you interact with a Panel (or any element of UI) its draw
function is called many times per second when your mouse moves.
As soon as you need to update objects or scene data via UI you should attach an update function to your properties or make dedicated operators (triggered by buttons).
Update Function
Please see this answer for why a ProperyGroup is a good idea to keep your properties organized. In the code below I've commented out where you would have an opportunity to react to the tickbox state. The update-response is part of the property not part of the draw function of a Panel.
import bpy
def common_update(self, context, origin):
if origin == 'my_bool_one':
print('button_one', getattr(self, origin))
# bpy.data.objects["Macbook_Gold"]["00_iSight Camera Indicator"] = getattr(self, origin)
if origin == 'my_bool_two':
print('button_two', getattr(self, origin))
class IgnitProperties(bpy.types.PropertyGroup):
my_bool_one = bpy.props.BoolProperty(
update=lambda self, context: common_update(self, context, 'my_bool_one')
)
my_bool_two = bpy.props.BoolProperty(
update=lambda self, context: common_update(self, context, 'my_bool_two')
)
class IGLayoutDemoPanel(bpy.types.Panel):
"""Creates a Panel in the scene context of the properties editor"""
bl_label = "IG Layout Demo"
bl_idname = "SCENE_PT_layout"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "scene"
def draw(self, context):
layout = self.layout
scene = context.scene
col = layout.column()
col.prop(scene.ignit_panel, "my_bool_one", text='option 1')
col.prop(scene.ignit_panel, "my_bool_two", text='option 2')
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.ignit_panel = bpy.props.PointerProperty(type=IgnitProperties)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.ignit_panel
if __name__ == "__main__":
register()
Operators
See the TextEditor > Templates -> Python -> Operator Simple