How can i cleanly declare and edit variables for use in an addon the don't need to be registered like a PropertyGroup but also aren't stored in the blend file?
I'm working off of the basic addon structure like so:
def boolPropVarAccess(self, context):
# Test accessing a 'global' variable declared at some other point in the addon structure
class MyProperties(PropertyGroup):
my_bool: BoolProperty(
name="Enable or Disable",
description="A bool property",
default = False,
update=boolPropVarAccess
)
class OBJECT_PT_CustomPanel(Panel):
bl_label = "My Panel"
bl_idname = "OBJECT_PT_custom_panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Tools"
@classmethod
def poll(self,context):
return context.object is not None
def draw(self, context):
layout = self.layout
scene = context.scene
mytool = scene.my_tool
# Declare some 'global' addon variable like an object reference
layout.prop(mytool, "my_bool")
layout.separator()
# ------------------------------------------------------------------------
# Registration
# ------------------------------------------------------------------------
classes = (
MyProperties,
OBJECT_PT_CustomPanel
)
def register():
from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.Scene.my_tool = PointerProperty(type=MyProperties)
def unregister():
from bpy.utils import unregister_class
for cls in reversed(classes):
unregister_class(cls)
del bpy.types.Scene.my_tool
if __name__ == "__main__":
register()
set up properties on the window manager using bpy.props? – Alexis.Rolland Aug 21 '21 at 05:22