How can I store a variable from within an extension

Asked by Windell Oskay on 2010-06-08

I'm writing an Inkscape extension, with a .inx and .py file.

My extension needs to perform a slightly different effect each time that the user hits the "Apply" button, and so it would be very helpful to find some way to save the state of the extension to know which effect we're supposed to apply next-- e.g., applying an effect to one layer at a time, where the layer effected auto-increments each time that you hit apply.

Ideally, I would store the variable, call it "effect number" as one of the visible parameters in the extension, and increment it automatically each time that the effect is applied. Is there any way to change a numeric value displayed in the extension panel from within the .py code? A gui-hidden variable would work as well. It is not necessary (or even desirable) that the state be preserved between subsequent times that the extension is selected from the menu.

Alternately (1), is there some way that I could store a value in the SVG file itself, without negative consequences?

Alternately (2), is there some variable-- like active layer --that could be incremented to store the variable?

Or, are there other, existing, ways to handle issues like this? I'm certainly open to suggestions.

Question information

Language:
English Edit question
Status:
Solved
For:
Inkscape Edit question
Assignee:
No assignee Edit question
Solved by:
jazzynico
Solved:
2015-12-16
Last query:
2015-12-16
Last reply:
2010-06-23
su_v (suv-lp) said : #1

related to two recently filed blueprints (not yet implemented):

Inkscape : Blueprints : Makes the render extensions be persistant to allow reedit of rendered objects
<https://blueprints.launchpad.net/inkscape/+spec/persistent-render-extensions>

Inkscape : Blueprints: Add a tool that automatically edit the parameters of an extension rendered effect
<https://blueprints.launchpad.net/inkscape/+spec/render-extension-wand>

Windell Oskay (windell) said : #2

I can see some resemblance to those two blueprints, but it's not clear that either would actually address my issue-- since I don't actually render an effect -- and I'm afraid that implementing either of them in a general sense is well beyond my skill level.

Best jazzynico (jazzynico) said : #3

I'm afraid there's no easy way to make the python file and the inx UI communicate. The last used UI values are stored in the preferences, and reused each time you open the extension. Trying to modify them directly in the preferences from the python file is the only workaround I see, but I'm not sure it's easy (or even possible) to implement it.

Windell Oskay (windell) said : #4

Sorry for the late reply here; just realized that this was still open. :)

Windell Oskay (windell) said : #5

Thanks jazzynico, that solved my question.