Re: [Gimp-user] Arrays in Python



It is just Python -

Just use on the calee script an inner function - one to be publicly
exposed on the PDB taking user arguments, and
another one internal meant to be called from other Python functions .

On this, simply use a Python list.

You can manipulate `sys.path` in order to be able to import other
installed GIMP scripts PY files.

Just don't expect the Procedural Database way of calling parameters,
essentially created more than
20 years ago with Scheme/lisp in mind to be able to handle the
flexibility one have in modern Python
parameter passing.

If you need the user to feed in several numbers on the UI, and wants
to use GIMP-FU,  (and not
design your own custom GTK UI), my suggestion is to use a string, and
tell the user to separate the nubmers by spaces
or commas  - on the Python side, you just split and convert the argument.

Other than that, yes, GIMp-Fu should be able to handle these PDB
arrays as arguments - despite
the workarounds I just described.
Could you can fill a bug in bugzilla about that?

Regards,

   js
 -><-

On 10 April 2018 at 04:03, Ofnuts <ofnuts gmx com> wrote:
On 04/10/18 00:57, Beinsezii wrote:

AFAIK you can't, but anyway how do you expect the user to enter the
bazillion numbers? If you want that many numbers just ask for a file
name and read the file.

The user already can. I wrote a custom system for making GTK configuration
windows that I use with all my plugins instead of the default python-fu
thing
that just stacks all the widgets into a grand tower of Babel.
Where the enums come into play is allowing other scripts to call this one
via
the PDB. Not really a problem right now since the registry's dead and
therefore
it won't end up in the hands of others for a while (right?). I'm just
perfectionist.


Guess for now I'll refactor it to make the PDB method take i32's & floats
instead of arrays, and if some other weirdo wants the full horror of my
plugin,
they'll just have to import the class.


If anyone else knows a way or has other inquiries, I'll stay subbed to
this
thread.




Or maybe your array can be pixels values in a layer (these are easy to
get in Python) in which case the user would just specify a second
layer.

You say that, but I was entirely unable to get proper pixel info in one of
my
past scripts. I could get standard 8-bit info, but no 32-bit floating
point info
that everything apparently uses now (2.10 RC-1).
Unless I'm completely missing it, the python-fu docs are patchy at best.
Most of
my knowledge comes from trying to interpret the auto-generated pydoc
stuff,
incomplete docs from like 4 years ago, or reverse engineering other
over-the-top
scripts like LayerFX.

I have rarely seen  a Python script use another, most people would just copy
the code they need to avoid the dependency. And you can factor you code to
have a class that does the work and a registration facade, so that other
Pythin script can import you code and call the useful code directly.


_______________________________________________
gimp-user-list mailing list
List address:    gimp-user-list gnome org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]