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

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

 



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>/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.
_______________________________________________
gimp-developer-list mailing list
List address:    gimp-developer-list@xxxxxxxxx
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@xxxxxxxxx
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list



[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux