I have a simple panel that you can see in the viewport which is a shorter version of UI Panel Simple. Seeing from other panels, by using Edit Source, they all define a context where the property is added, but how do I decide which one to use to get it working? Using Blender 2.92.
import bpy
from bpy.props import BoolProperty
class HelloWorldPanel(bpy.types.Panel):
bl_label = "Hello World Panel"
bl_idname = "OBJECT_PT_hello"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Tool"
def draw(self, context):
layout = self.layout
row = layout.row()
row.label(text="Hello world!", icon='WORLD_DATA')
class QuickRename_PT_Panel(bpy.types.Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_label = "Quick Rename"
bl_category = "Tool"
bl_parent_id = "OBJECT_PT_hello"
testBool: BoolProperty(
name = 'Test',
description = 'Test description',
default = True,)
def draw(self, context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
tool_settings = context.tool_settings
row = layout.row()
row.prop(tool_settings, 'testBool')
def register():
bpy.utils.register_class(HelloWorldPanel)
bpy.utils.register_class(QuickRename_PT_Panel)
def unregister():
bpy.utils.unregister_class(QuickRename_PT_Panel)
bpy.utils.unregister_class(HelloWorldPanel)
if name == "main":
register()
I want to add the testBool property to the Hello World Panel.

But I think the
tool_settings = context.tool_settings
is wrong.
bpy.types.ToolSettings.test_bool = bpy.props.BoolProperty()then in python console type inC.tool_settings.test_boolIf it is notTrue or False' can't do it. – batFINGER Apr 12 '21 at 06:16