Properties depending of a panel / space view?

Hello,
Usually to create properties, I store it in the bpy.context.scene. But I would like to have the possibilities to set different value for each view like other properties that already exists (“Lock to Cursor” or “Local Camera” in the 3D view space)

I tried to store it in “Space”:
bpy.types.Space.my_prop = bpy.props.BoolProperty()
Or
bpy.types.SpaceView3D.my_prop = bpy.props.BoolProperty()

And call them by “space_data”
layout.prop(context.space_data, “my_prop”)

But nothing is displayed.

What am I doing wrong?

Thanks!

Space and Area types are not ID types, and thus do not support properties.

Oh, Ok. I didn’t know that only ID types was supporting properties, at least for displaying it in the UI. It seems to be working if I just store properties anywhere. I already did it for bpy.type.Nodes and it was working but maybe that wasn’t a good idea?

A list of ID types can be found here:
http://www.blender.org/api/blender_python_api_2_75_release/bpy.types.ID.html (subclasses of bpy.types.ID)

In addition, all 3 types of Bones support properties as well.

If it works for a not supported type in UI, well thats good, but it will certainly not be persisted in the blend.

Do you mean, after saving the .blend and reopen it?
This is working quite well :

bpy.types.Node.my_prop = bpy.props.BoolProperty(
    name = "Use",
    default = 0,
)

I can change the value, save it and it will be keep in the file.
Is it not correct to do that?

bpy.types.Node seems to be supported as well, but it’s not mentioned in the docs… It does not work for Spaces and Areas for sure however.