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



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?

2) How can I refresh the script? So far I restart gimp but that is 
getting tedious.

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

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()
1. To display information in a Python script you can use something like the
following example:

pdb.gimp_message('The times are ' + str(sixteenth_time) + " " +
str(eighth_time) + " " + str(quarter_time)+ " " + str(half_time))

("\n" will give you a newline(note the double quotes in this case))

2. If I remember correctly (its a while since I debugged a Python script) you
just edit and save the script using a text editor and GIMP will then use the
updated version when you next run the script (might be best not to save the
script whilst part way through actually running the script). (For Script-Fu you
also don't need to restart GIMP just use "Filters/Script-Fu/Refresh Scripts"
then wait for a few seconds until the refresh is complete)

-- 
programmer_ceds (via www.gimpusers.com/forums)


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