Re: [Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.

2018-05-25 Thread Kevin Cozens

On 2018-05-23 08:00 AM, Kevin Payne wrote:

A bit of Googling leads to the conclusion that PF_STRINGARRAY only exists
in a hacked version of gimpfu.py so isn't a standard part of GIMP


I looked at the code for pygimp. Since 2004 the 5 array types are commented 
out. From what I saw in the code the array types were going to be handled as 
a list.


--
Cheers!

Kevin.

http://www.ve3syb.ca/   | "Nerds make the shiny things that
https://www.patreon.com/KevinCozens | distract the mouth-breathers, and
| that's why we're powerful"
Owner of Elecraft K2 #2172  |
#include  | --Chris Hardwick
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.

2018-05-23 Thread Kevin Payne
>I'm trying to write a very basic plugin for Gimp using Python and I
>want its one and only parameter to be of type PF_STRINGARRAY. The goal
>of my plugin for the time being, is to receive a list of files, and
>then simply print their names on the Command line, when the plugin is
>run.

A bit of Googling leads to 
the conclusion that PF_STRINGARRAY only exists in a hacked version of gimpfu.py 
so isn't a standard part of GIMP as shipped.
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.

2018-05-23 Thread Ofnuts
If you want to run the script as a batch it doesn't need (and really 
shouldn't be) a plugin. Then your code is just a plain Python function 
that takes string parameters, and you don't need to register it. See


https://stackoverflow.com/questions/44430081/how-to-run-python-scripts-using-gimpfu-from-windows-command-line/44435560#44435560



On 05/23/18 02:17, Craig Sanders wrote:

Hello.

I'm trying to write a very basic plugin for Gimp using Python and I
want its one and only parameter to be of type PF_STRINGARRAY. The goal
of my plugin for the time being, is to receive a list of files, and
then simply print their names on the Command line, when the plugin is
run.

The code for my plugin is as follows;


BEGIN CODE SEGMENT >

from gimpfu import register, main, pdb, PF_STRINGARRAY


def \
process_list_of_files(

   listOfFiles
) :

for filename in listOfFiles :

print("")
print("Filename = %s" % filename)
print("")


register(
"process-list-of-files",# The name of the command
"Process a list of files",  # A brief description of the 
command
"Process a list of files",  # Help message
"John Doe", # Author
"John Doe", # Copyright holder
"2018", # Date
"/Image/Process list of files",  # The way the script will be
referred to in the menu
"RGB*, GRAY*",  # Image mode
[
(PF_STRINGARRAY, "listOfFiles", "List of files", [""])
],
[],
process_list_of_files,
menu="/File/ProcessListOfFiles")


main()

< END CODE SEGMENT <

I then run this plugin from the Command line using the following command;

gimp --no-interface --verbose --console-messages
--batch-interpreter='plug-in-script-fu-eval' --batch
'(python-fu-process-list-of-files RUN-NONINTERACTIVE
["/home/john/test.txt"])' --batch "(gimp-quit 1)"

Unfortunately, it doesn't work for me and complains with the messages;

Starting extension: 'extension-script-fu'
batch command experienced an execution error

If I now change my plugin's parameter type to be PF_STRING, and update
my code and Command line invocation method accordingly, it works! I
know that I could get around this problem by passing filenames in as
one string, where the filenames are separated by the ":" character,
but I want the code in the plugin to be as simple as possible.

So I guess my question is; is the PF_STRINGARRAY type supported, or am
I doing something wrong? I am using Gimp version 2.6.9.

Any help would be immensely appreciated.

Thanks in advance.
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list



___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list


Re: [Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.

2018-05-22 Thread Carol Spears
On Tue, May 22, 2018 at 8:17 PM, Craig Sanders  wrote:

> Hello.
>
> I'm trying to write a very basic plugin for Gimp using Python and I
> want its one and only parameter to be of type PF_STRINGARRAY. The goal
> of my plugin for the time being, is to receive a list of files, and
> then simply print their names on the Command line, when the plugin is
> run.
>

Huh. If I ever knew that PF_STRINGARRAY existed, it did not sink into the
gray matter much.

Try this, instead, perhaps.  It has the limitation of delivering all of the
files in the directory however:

Hmm, I have been doing this in two steps:

import os

def list_directory(directory):
cennotts = os.listdir(directory)
contents = sorted(cennotts)
return contents

def list_directory_ext(directory, ext):
total_contents = list_directory(directory)
contents = []
for content in total_contents:
if content.endswith(ext):contents.append(content)
return contents

They work with (PF_DIRNAME, "img_dir",   "Images directory", ""),

carol
___
gimp-developer-list mailing list
List address:gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list