Gimp-Forum.net
Help! Unable to register Python script - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Help! Unable to register Python script (/Thread-Help-Unable-to-register-Python-script)



Help! Unable to register Python script - david - 10-24-2018

My first attempt at trying to modify an actual Python script.

I have taken the Uncrop script of Lloyd Konneker and modified it (using the Bluefish Editor) so that it "uncrops" on the left-hand side.
I was able to register this as uncrop-side1.py.

My next step was to add another slider so that I could specify the sample-width for the resynthesizer. However, all my attempts to register this as uncrop-side2.py have come to nothing!

I am obviously making a stupid mistake, but several days of searching has not helped. If someone could point out my obvious error it would be much appreciated.

I have substituted the appropriate parameters into uncrop-side1.py (without re-registering) to "uncrop" right, top and bottom, and that all worked. The intention was to add an additional PF_OPTION or PF_RADIO to select the side to uncrop and then re-register it under a suitable name. The end result will probably be of little value, but a useful education for me!

Attached are the two files - uncrop-side1 - (working) and uncrop-side2 - (not registering).

david.


RE: Help! Unable to register Python script - Ofnuts - 10-24-2018

(10-24-2018, 04:47 PM)david Wrote: My first attempt at trying to modify an actual Python script.

I have taken the Uncrop script of Lloyd Konneker and modified it (using the Bluefish Editor) so that it "uncrops" on the left-hand side.
I was able to register this as uncrop-side1.py.

My next step was to add another slider so that I could specify the sample-width for the resynthesizer. However, all my attempts to register this as uncrop-side2.py have come to nothing!

I am obviously making a stupid mistake, but several days of searching has not helped. If someone could point out my obvious error it would be much appreciated.

I have substituted the appropriate parameters into uncrop-side1.py (without re-registering) to "uncrop" right, top and bottom, and that all worked. The intention was to add an additional PF_OPTION or PF_RADIO to select the side to uncrop and then re-register it under a suitable name. The end result will probably be of little value, but a useful education for me!

Attached are the two files - uncrop-side1 - (working) and uncrop-side2 - (not registering).

david.

Just start Gimp in a terminal... you'll see:

Code:
Traceback (most recent call last):
  File "/path/to/plugin-uncrop-side2.py", line 126, in <module>
    (PF_SLIDER, "sampleWidth", _("Sample Width"), 50, (10, 250, 1))
TypeError: 'tuple' object is not callable


This is because you are missing the comma at the end of the line before, so Python thinks you are doing:
Code:
(PF_SLIDER, "percentEnlargeParam", _("Percent enlargement"), 5, (1, 25, 1))(PF_SLIDER, "sampleWidth", _("Sample Width"), 50, (10, 250, 1))
In other words, calling  the tuple (PF_SLIDER, "percentEnlargeParam", _("Percent enlargement"), 5, (1, 25, 1)) with argments PF_SLIDER, "sampleWidth", _("Sample Width"), 50, (10, 250, 1).


RE: Help! Unable to register Python script - david - 10-24-2018

Ofnuts,

Many thanks! I have spent several days trying to find the mistake. I knew it had to be something simple, but it escaped me continually.

Also, I must apologize for putting my query in the wrong thread.

Again many thanks for your help.

david.