[SOLVED] Bool Property Not Working (registration Issue?)

I am working on a test addon that displays property UI controls.

I am getting an error that says… “‘Scene’ object has no attribute ‘my_tool’”
It seems to be a registration issue, but don’t know how to fix this error

I have searched and tried many code examples, but they they don’t work with ver 2.81

Here is my code…

bl_info = {
    "name": "PS Test",
    "description": "PS Test",
    "author": "Pixelink Software",
    "version": (0, 0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "wiki_url": "",
    "tracker_url": "",
    "category": "3D View"
}

import bpy
from bpy.props import (StringProperty,
                       BoolProperty,
                       IntProperty,
                       FloatProperty,
                       EnumProperty,
                       PointerProperty,
                       )
from bpy.types import (Panel,
                       Operator,
                       PropertyGroup,
                       )


class MySettings(PropertyGroup):

    my_bool = BoolProperty(
        name="Enable or Disable",
        description="A bool property",
        default = False
        )

    my_int = IntProperty(
        name = "Int Value",
        description="A integer property",
        default = 23,
        min = 10,
        max = 100
        )

    my_float = FloatProperty(
        name = "Float Value",
        description = "A float property",
        default = 23.7,
        min = 0.01,
        max = 30.0
        )

    my_string = StringProperty(
        name="User Input",
        description=":",
        default="",
        maxlen=1024,
        )
        
    my_enum = EnumProperty(
        name="Dropdown:",
        description="Apply Data to attribute.",
        items=[ ('OP1', "Option 1", ""),
                ('OP2', "Option 2", ""),
                ('OP3', "Option 3", ""),
               ]
        )
        
class WM_OT_HelloWorld(bpy.types.Operator):
    bl_label = "Print Values Operator"
    bl_idname = "wm.hello_world"

    def execute(self, context):
        scene = context.scene
        mytool = scene.my_tool
        
        # print the values to the console
        print("Hello World")
        print("bool state:", mytool.my_bool)
        print("int value:", mytool.my_int)
        print("float value:", mytool.my_float)
        print("string value:", mytool.my_string)
        print("enum state:", mytool.my_enum)
        
        return {'FINISHED'}

class OBJECT_PT_CustomPanel(Panel):
    bl_label = "PS Tests"
    bl_idname = "OBJECT_PT_custom_panel"
    bl_category = "PS Test"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI" 

    # @classmethod
    # def poll(self,context):
    #     return context.object is not None

    def draw(self, context):
        layout = self.layout
        myscene = context.scene
        mytool = myscene.my_tool

        layout.prop(mytool, "my_bool", text="Bool Property")
        layout.prop(mytool, "my_enum", text="Enum Property") 
        layout.prop(mytool, "my_int", text="integer Property")
        layout.prop(mytool, "my_float", text="Float Property")
        layout.prop(mytool, "my_string", text="String Property"")
        layout.operator("wm.hello_world", text="Hellow World")
        layout.separator()

def register():
    bpy.utils.register_class(OBJECT_PT_CustomPanel)
    #bpy.types.Scene.my_tool = PointerProperty(type=MySettings)
    bpy.types.Scene.my_tool = BoolProperty(name="my_bool")

def unregister():
    bpy.utils.unregister_class(OBJECT_PT_CustomPanel)
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()

From 2.80 Release Notes:

Classes that contain properties from bpy.props now use Python’s type annotations (see PEP 526) and should be assigned using a single colon : in Blender 2.8x instead of equals = as was done in 2.7x:

So: my_bool = BoolProperty --> my_bool: BoolProperty

I used… bpy.types.Scene.my_tool:BoolProperty(name=“my_bool”)

Same error
‘Scene’ object has no attribute ‘my_tool’

Ah, the group registration was commented out. But you’re still trying to access the BoolProperty from that.

    def draw(self, context):
        layout = self.layout
        myscene = context.scene
        mytool = myscene.my_tool

        layout.prop(myscene, "my_tool", text="Bool Property")
#        layout.prop(mytool, "my_enum", text="Enum Property") 
#        layout.prop(mytool, "my_int", text="integer Property")
#        layout.prop(mytool, "my_float", text="Float Property")
#        layout.prop(mytool, "my_string", text="String Property")
#        layout.operator("wm.hello_world", text="Hellow World")
        layout.separator()

With this, the BoolProperty works.

Btw, in register function, it’s still bpy.types.Scene.my_tool = BoolProperty(name=“my_bool”), no single colon.

Getting closer… at least the panel displays in 3D View… But it doesn’t show the Checkbox
And I now get this error…
rna_uiItemR: property not found: Scene.my_bool
on this line… layout.prop(myscene, “my_bool”, text=“Bool Property”)

CODE (I stripped it down to just the bool)

bl_info = {
    "name": "PS Test",
    "description": "PS Test",
    "author": "Pixelink Software",
    "version": (0, 0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "wiki_url": "",
    "tracker_url": "",
    "category": "3D View"
}

import bpy
from bpy.props import (StringProperty,
                       BoolProperty,
                       IntProperty,
                       FloatProperty,
                       EnumProperty,
                       PointerProperty,
                       )
from bpy.types import (Panel,
                       Operator,
                       PropertyGroup,
                       )


class MySettings(PropertyGroup):

    my_bool = BoolProperty(
        name="Enable or Disable",
        description="A bool property",
        default = False
        )

class WM_OT_HelloWorld(bpy.types.Operator):
    bl_label = "Print Values Operator"
    bl_idname = "wm.hello_world"

    def execute(self, context):
        scene = context.scene
        mytool = scene.my_tool
        
        # print the values to the console
        print("Hello World")
        print("bool state:", mytool.my_bool)
        print("int value:", mytool.my_int)
        print("float value:", mytool.my_float)
        print("string value:", mytool.my_string)
        print("enum state:", mytool.my_enum)
        return {'FINISHED'}

class OBJECT_PT_CustomPanel(Panel):
    bl_label = "PS Tests"
    bl_idname = "OBJECT_PT_custom_panel"
    bl_category = "PS Test"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI" 

    # @classmethod
    # def poll(self,context):
    #     return context.object is not None

    def draw(self, context):
        layout = self.layout
        myscene = context.scene
        mytool = myscene.my_tool

        layout.prop(myscene, "my_bool", text="Bool Property")
        layout.separator()

def register():
    bpy.utils.register_class(OBJECT_PT_CustomPanel)
    bpy.types.Scene.my_tool = BoolProperty(name="my_bool")

def unregister():
    bpy.utils.unregister_class(OBJECT_PT_CustomPanel)
    del bpy.types.Scene.my_tool

if __name__ == "__main__":
    register()

You’re registering my_tool, not my_bool.

I am using 2.81, I found a solution that worked. Its a little different.

bl_info = {
    "name": "PS Test",
    "description": "PS Test",
    "author": "Pixelink Software",
    "version": (0, 0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "warning": "", # used for warning icon and text in addons panel
    "wiki_url": "",
    "tracker_url": "",
    "category": "3D View"
}

import bpy

def update_func(self, context):
    for obj in bpy.data.objects:
        if (self.my_bool == True):
            #obj.hide = True
            bpy.context.space_data.lock_camera = True
        else:
            #a = obj.hide=False
            #print(a)
            bpy.context.space_data.lock_camera = False
            
def update_func_1(self, context):
    for obj in bpy.data.objects:
        if (self.my_bool1 == True and obj.name=="Cube"):
            #obj.hide = True
            bpy.context.space_data.lock_camera = True
        else:
            #obj.hide = False
            bpy.context.space_data.lock_camera = False
            
class My_settings(bpy.types.PropertyGroup):
    my_float: bpy.props.FloatProperty(
        name='Float',
        default=0.0 
    )

    my_bool: bpy.props.BoolProperty(
        name='Boolean Checkbox',
        default=False,
        update = update_func
    )
    
    my_bool_1: bpy.props.BoolProperty(
        name='Boolean Checkbox',
        default=False,
        update = update_func_1
    )

            
class TEST_PT_panel(bpy.types.Panel):
    bl_label = "PS Tests"
    bl_idname = "OBJECT_PT_custom_panel"
    bl_category = "PS Test"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI" 

    def draw(self, context):
        layout = self.layout
        my_tool = context.scene.my_tool

        layout.label(text="Test label")

        row = layout.row()
        row.prop(my_tool, "my_bool", text="Boolean CheckBox")
        row = layout.row()
        row.prop(my_tool, "my_float")
       
    
classes = (
    My_settings,
    TEST_PT_panel,
)


def register():
    for cls in classes:
        bpy.utils.register_class(cls)
    bpy.types.Scene.my_tool = bpy.props.PointerProperty(type=My_settings)

def unregister():
    del bpy.types.Scene.my_tool
    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)

if __name__ == "__main__":
    register()

Thanks for the help