I'm trying to create a Python extension for a custom export format that associates JSON elements to SVG objects depending on the SVG object's properties. Such dependency should be configurable by the user and there could be as many associations as the user wants. For this, the GUI should be dynamic, i.e. whenever the user clicks on a '+' button, the GUI should show one filed more for configuring an association.
I cannot understand how to do this with inkex. Can I use pyGTK or another GUI library without needing to distribute it?
I think you would have to use the python configparser and create your own .ini file.
I have asked the developers before, they said that extensions should never write to the extension folder.
However .ini files created by configparser (which is a python core module) is okay if in the subfolder that belongs to that extension (not in the extension root folder)
I'm just a hobby programmer:
I made myself a page numbering extension a while ago, it has a module called font_chooser.py
It saves user selected font settings to an ini file and loads them in the main extension
Thank you for your help! Anyway, your method won't work if the user installa the extension system-wide in a directory where it has no write permissions. For writing configuration and cache files, you should use the operating system recognized standards, in Linux it's ~/.config and ~/.cache
Hello,
I'm trying to create a Python extension for a custom export format that associates JSON elements to SVG objects depending on the SVG object's properties. Such dependency should be configurable by the user and there could be as many associations as the user wants. For this, the GUI should be dynamic, i.e. whenever the user clicks on a '+' button, the GUI should show one filed more for configuring an association.
I cannot understand how to do this with inkex. Can I use pyGTK or another GUI library without needing to distribute it?
Yes.
Inkscape provides several python packages out of the box - this is really good for windows users.
You get numpy, GTK3 and some others.
So if you build a GTK3 application you can use that as the extension custom GUI in Inkscape.
https://gitlab.com/inklinea/inkscape-basic-gtk3
Great! I'm doing it, now! Is there any recommended way save the configuration when using custom GTK interfaces? Or should I use a custom cached file?
I think you would have to use the python configparser and create your own .ini file.
I have asked the developers before, they said that extensions should never write to the extension folder.
However .ini files created by configparser (which is a python core module) is okay if in the subfolder that belongs to that extension (not in the extension root folder)
I'm just a hobby programmer:
I made myself a page numbering extension a while ago, it has a module called
font_chooser.py
It saves user selected font settings to an ini file and loads them in the main extension
https://gitlab.com/inklinea/page-numbering
Thank you for your help! Anyway, your method won't work if the user installa the extension system-wide in a directory where it has no write permissions. For writing configuration and cache files, you should use the operating system recognized standards, in Linux it's ~/.config and ~/.cache