[Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.
- From: Craig Sanders <craig sanders gimp gmail com>
- To: gimp-developer-list gnome org
- Subject: [Gimp-developer] Problems using the PF_STRINGARRAY parameter type when writing a Python plugin for Gimp.
- Date: Wed, 23 May 2018 10:17:30 +1000
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>/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="<Image>/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.
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]