Re: [Gimp-user] Copy text layers as text or python script to mass generate text layers



On 09/25/17 18:37, The Tick wrote:

I found the docs for gimp python; now:

1) How to get "print" statments? I started filters->python fu->console but apparently a "print" does not write to the console?
It does for me... if you enter the "print" on the console. "Print" from a script started form a menu goes to the standard output, whicn on Linux and OSX, is the terminal from which your invoked Gimp. For Windows, things are a bit more complicated, see here: https://www.gimp-forum.net/Thread-Debugging-python-fu-scripts-in-Windows

2) How can I refresh the script? So far I restart gimp but that is getting tedious.
You don't need to, as long as you don't change the registration data. The code is reloaded from the file on each execution; so your latest chnages
to the code will be taken in account.

3) Is there an online site with hints on how to debug a gimp python script?

https://www.gimp-forum.net/Thread-Debugging-python-fu-scripts-in-Windows


For reference, here is the script. It apparently runs but I get no new layer and no progress/console output. I did not expect it to work first time so now I'd like some pointers on how to debug it.


from gimpfu import *

def mass_text(img) :
    print "Does this go to console?"

    pdb.gimp.progress_init("Mass text insert ...")

    font = 'Arial Bold'

    pdb.gimp.set_foreground( 1.0, 0.0, 0.0 )

    # Create a new text layer (-1 for the layer means create a new layer)
    layer = pdb.gimp_text_fontname(img, None, 0, 0, "This is my text", 10,
                                   True, 24, PIXELS, font)
    img.add_layer(layer, 0)


register(
    "python_fu_mass_text",
    "Mass Text",
    "Mass create text layers",
    "",
    "",
    "",
    "Mass Text Layer insert...",
    "*",
    [
    ],
    [],
    mass_text, menu="<Image>/Tools/MassText")

main()

Try:
    pdb.gimp_context_set_foreground((1.,0,0,0))

Also, the " img.add_layer(layer, 0)" isn't necessary, the layer created in  gimp_text_fontname() is added to the image automatically.

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