1
$\begingroup$

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!

$\endgroup$
1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ Dec 22 '20 at 12:23
  • $\begingroup$ I would go with window manager. There is only one window manager, could have multiple scenes. $\endgroup$
    – batFINGER
    Dec 22 '20 at 12:31
  • $\begingroup$ Okey, got it, thanks! $\endgroup$ Dec 22 '20 at 12:56

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.