1

Is there a way of reseting a text field every time Blender is initiated, saved or before closing? I want to create a password field for an Addon and I don't want it's value to be saved alongside the blend file.

I have looked for a while but I haven't seen anyone asking this particular subject.

A little bit of code:

row.prop(scene.testing, "password")

Password being a String Property created like this:

password: StringProperty(
        name="Password",
        description="Password",
        default="",
        subtype="PASSWORD")

If it could be possible to reset to the default value which is "", that would be perfect, but I don't seem to find anything.

Thanks!

S. Dre
  • 113
  • 5

1 Answers1

1

Use the window manager.

Related How to declare global variables for use in an addon that aren't stored in the blend file

For a session variable suggest using the window manager. Will always be default when new blender is openened. No window manager property is saved directly.

bpy.types.WindowMangager.password =  StringProperty(
        name="Password",
        description="Password",
        default="",
        subtype="PASSWORD")

SKIP_SAVE

Also look at using the skip save option of a property.

Force a Blender operator to always start with default values

Onload handler.

How to set blender default properties in addons?

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • Thanks for the answer! I didn't expect such a clean one! Just a question, are WindowManager Properties registered the same way as the other ones? I guess the Window Manager option is cleaner than the Skip save one, isn't it? – S. Dre Dec 22 '20 at 12:23
  • I would go with window manager. There is only one window manager, could have multiple scenes. – batFINGER Dec 22 '20 at 12:31
  • Okey, got it, thanks! – S. Dre Dec 22 '20 at 12:56