08-15-2023, 04:50 PM
Hi there,
I sometimes bump into inconsistencies in the python script documentation (or things that look like so to me, I'm not at all an expert).
Here is an example : the gimp_image_insert_layer's documentation displayed in the python procedure navigator is :
But specifying 0 as parent returns an error
after struggling a little, I found out that you should use None instead of 0
From my point of view, the documentation should be modified (correct me if I'm wrong).
It's not a bug as such, but maybe it would be useful to report it through the bug report procedure ?
I sometimes bump into inconsistencies in the python script documentation (or things that look like so to me, I'm not at all an expert).
Here is an example : the gimp_image_insert_layer's documentation displayed in the python procedure navigator is :
Quote:This procedure adds the specified layer to the image at the given position. If the specified parent is a valid layer group (See 'gimp-item-is-group' and 'gimp-layer-group-new') then the layer is added inside the group. If the parent is 0, the layer is added inside the main stack, outside of any group. The position argument specifies the location of the layer inside the stack (or the group, if a valid parent was supplied), starting from the top (0) and increasing. If the position is specified as -1 and the parent is specified as 0, then the layer is inserted above the active layer, or inside the group if the active layer is a layer group. The layer type must be compatible with the image base type.
But specifying 0 as parent returns an error
Code:
➤> img=gimp.image_list()[0]
➤> layer = pdb.gimp_layer_new(img, 100, 100, RGB_IMAGE, "layer", 100, 0)
➤> pdb.gimp_image_insert_layer(img, layer, 0, 0)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: wrong parameter type
➤>
after struggling a little, I found out that you should use None instead of 0
Code:
➤> img=gimp.image_list()[0]
➤> layer = pdb.gimp_layer_new(img, 100, 100, RGB_IMAGE, "layer", 100, 0)
➤> pdb.gimp_image_insert_layer(img, layer, None, 0)
➤> img.layers
[<gimp.Layer 'layer'>, <gimp.Layer 'Arrière-plan'>]
➤>
It's not a bug as such, but maybe it would be useful to report it through the bug report procedure ?