You are here

SOLVED: Python-fu and Glade and howto remember the setting

Hi,
I'm working on conversion of my Line Border script from script-fu to python-fu + Glade, because the script parameter dialogue does not fit to screen. The Glade interface is powerful and I'm able to implement much more functionality.

There is one problem. Script is registered without parameters, so each run of script means that default values are used. With the standard python-fu interface the previous values are remembered and user is able to correct only one wrong setting, rest remain from previous run.

The solution could be to store somewhere the setting and restore it when is script called again. I'm planning to implement profiles support (save/load current setting) so I need to know whether there is some special gimp variable/directory, where it could be stored. Is there something like this? Or I should use temp directory to store the previous setting and some own directory to store profiles?

Maybe this could be solved by gimp developers - add support for glade dialogues: allow to register script with parameters, but do not generate the python-fu parameter dialogue when glade file is present. This allows batch mode and gimp could re-run the script with the same parameters like last time.

So I used the ConfigParser python module and I'm storing the configuration file directly in the users gimp directory (~/.gimp-2.6 on linux).

It works good, the batch mode is still not possible, but now Gimp remembers plugin setting between sessions. See my script for details (http://registry.gimp.org/node/24784)

And as I found, there will be even batch mode possible, it needs only to "re-implement" the gimpfu class. Maybe I will try it in future.

Great I already studied your source about this.

One thing instead of putting the configuration file into the gimp directory why not putting it into the lineborder directory?? Removing the plugin then leaves no traces behind.

Hi,
I'm not sure about it. It could be "dangerous" for users. They can lost their configuration if the directory will be removed by mistake. Now it could be not a big problem, but in future, many profiles could be stored there.

Yes I am aware of that but I find it a responsibilty of the users and besides that there exist a recover procedure from the trash;)

Nice try :-)
I think, for now I'll leave it as is and I'll add uninstallation instructions to the plugin page. It is one more step only ;-)

One more thing. It is not necessary that the script will be installed only in the user folder. It could happen, that administrator will install it to system folders to allow it for all users. In this case the LineBorder directory will be not in user folder and the system folders are not writeable for users.

Thanks, you are right, I hadn't thought about that.

Subscribe to Comments for "SOLVED: Python-fu and Glade and howto remember the setting"