Plugin with properties to be remembered

With this XML I can specify a file name attribute for a plugin:

  <StringVectorProperty
      name="AttributesFile"
      label="Attributes File"
      command="SetAttributesFile"
      number_of_elements="1">
    <FileListDomain name="files"/>
    <Documentation>
      Specify a CSV file that contains the attributes to be assigned
    </Documentation>
  </StringVectorProperty>

ParaView will automatically generate the required widgets and functionality to allow the user to select a file.

What I like to achieve: Once the user has selected a filename with path, the program “remembers” it in the settings and presents it again if the plugin filter is used again, also after a program restart.

Saving to the settings can be achieved if I do it in the filter itself: In that case the saving occurs only if the user not only selects a file, but also presses “Apply” - which is ok.

However, for restoring the file name I see so far only one way: write my own property widget. I have done that many times, but I was asking myself if there isn’t a way that I can do that in a more simple way, like with some settings or code in the XML. Is there such a “secret trick”?

The SaveSettings button ?a

True - that would be a solution that is in the hands of the user himself!

I was thinking of a solution where saving and reloading is automatic, but swimming against the conventions of ParaView is a) always tedious and b) maybe also confusing for the user.

You can use a domain for this. Domains are called to reset properties to default values during creating. Maybe create a vtkSMFileListDomain subclass that can set the value to something from settings? The tricky thing would be saving the updated value to settings. You’ll probably need to observe modified event on the property in this domain and save that to settings.

A generalized implementation for the same in vtkSMDomain or something like that maybe possible too.