GIMP Version: 2.8.16
Operating System: Windows
GIMP Experience: Basic Level
List any ERROR messages you received:TypeError: object of type 'NoneType' has no len()
I'm trying to create the elementary base for a main python filter which -at a certain point- needs to get an array created by an ancillary python function.
I coded the ancillary function (as an example) as such:
#!/usr/bin/env python
from gimpfu import *
def get_array (nrc):
array = []
for c in range (0, int(nrc)):
array.append(10*c)
gimp.message ("executed")
gimp.message ("first value = "+str(array[0]))
gimp.message ("last value = "+str(array[c]))
gimp.message ("number of values = "+str(len(array)))
return(array)
register(
"get_array",
"to test creating and returning an array",
"This script tests how creating and returning an array",
"Diego",
"Diego Nassetti ",
"March 2016",
"get_array",
"",
[
(PF_ADJUSTMENT, "howmany", "how many values", 12, (4, 64, 1)),
],
[],
get_array,
menu="<Image>/DiegoTest"
)
main()
If called directly it display all the expected messages:
getarray Warning
executed
getarray Warning
first value = 0
getarray Warning
last value = 110
getarray Warning
number of values = 12
Then I created (again as an example) a caller as such:
#!/usr/bin/env python
from gimpfu import *
def Test_Call2 (inNr) :
values = [] # values is an empty array (a list) initially
values = (pdb.python_fu_get_array (inNr))
c = len(values)
gimp.message ("last value = "+str(values[c]))
return()
register(
"Test_Call2",
"to test calling the Get_Array",
"This script tests how calling the Get_Array",
"Diego",
"Diego Nassetti ",
"March 2016",
"Test Call Get Array",
"",
[
(PF_ADJUSTMENT, "howmany", "how many values", 12, (5, 24, 1)),
],
[],
Test_Call2,
menu="<Image>/DiegoTest"
)
main()
If I launch the caller I get:
- first all the messages listed above issued by the called ancillary function, then the error indicated in the "List any ERROR...", i.e.
TypeError: object of type 'NoneType' has no len()The error in the code of my caller is likely very stupid, but because I'm novice on python I cannot identify it.
Can some expert in Python tell me what is wrong in the caller (or in the return statement of the called)? Thanks a lot !