I can create a checkbox with bpy.props.BoolProperty. I can set a default for it. True or False. Let's say we start with False. And my user wants the value to be True. Permanently. The problem is, when i restart Blender, then the bool is reset to the default value. And this also when i save the user preferences or the startup.blend

Is there a way to save the current state of the BoolProperty so that the user doesn't have to adjust it all the time?


import bpy

class LayoutDemoPanel(bpy.types.Panel):
    bl_label = "Checkbox"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'

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

        wm = context.window_manager # Our bool is in the windows_manager
        layout.prop(wm, "checkbox_bool") # Our checkbox

def register():
    #Our bool
    bpy.types.WindowManager.checkbox_bool = bpy.props.BoolProperty(
    name="A checkbox", description="Do this or that", default = False)

def unregister():
    del bpy.types.WindowManager.checkbox_bool # Unregister our flag when unregister.

if __name__ == "__main__":

The window-manager is an exception when it comes to data-blocks, having some characteristics that make it work differently then meshes, scenes... etc.

  • Can't be added or removed.
  • Its a singleton (there is only ever one).
  • Its not saved in the blend file (this is why properties aren't set on reload).

This can be handy, for example - this is used for the add-on and key-map search text fields.

For persistent data, its normally best to use...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.