On Wednesday 01 June 2005 22:39, Rikard Johnels wrote:
> I have been trying to get Gimp Perl to run without success for a
> while now. I have decided to try another way..
> The script i want to run is as follows;
>

I do not know much perl, but it is quite straightforward.
I suppose you know that in python identation does matter, and is used 
to separate blocks, instead of {  &  }  or begin & end.

That said, the script bellow becomes:

(I will let the perl lines commented on the script. you may erase then 
later)

#!/usr/bin/python

#use Gimp qw( :auto );
#use Gimp::Fu;
# I don't know what this "auto:" means,
#but we normally just import gimpfu in python scripts/

from gimpfu import *

#register        "center_guide",
# the register call in python must come after the function definition 
#itself. Ok - this is  thasy perl way, in which the function was
#defined inside the funcion call for register. Python is  a clean
#language - the only way of doing this is with short functions
#that can be written as lambdas.

#        sub {
#                my ($img, $layer, $center) = @_;
def center_guide (img, layer, center):
     #beware of indentation from this point on

     #$w = $img->width();
     #$h = $img->height();
     #$hc = int($h/2 + 0.5);
     #$vc = int($w/2 + 0.5);

     w = img.width
     h = img.height
     hc = int (h / 2.0 + 0.5)
     vc = int (w / 2.0 + 0.5)

     #if ($center == 1) {
     #      $hc = int(($h / 2.6179) + 0.5);
     #    };
     if center == 1:
          hc = int (h / 2.6179 + 0.5)

     #          $bit_bucket = $img->add_hguide($hc);
     #          $bit_bucket = $img->add_vguide($vc);
     #          gimp_drawable_update($layer, 0, 0, $w, $h);
     img.add_hguide (hc)
     img.add_vguide (vc)
     gimp.displays_flush()      

     #   };

register   ("center_guide",
            "Creates h- & v-guides at the center of the image.",
            "Physical center = width/2 and height/2; Optical center = 
the Golden Mean.",
             "Claes G Lindblad <[EMAIL PROTECTED]>",
             "Claes G Lindblad, pythonified by Joao S. O. Bueno 
Calligaris",
              "990323",
              "<Image>/Center Guides",
              "*",
              [
                [PF_RADIO,
                        "center",
                        "center",
                         0,
                         (("Physical", 0), ("Optical", 1))
                ]
                      
              ],
              [],
              center_guide
              )  
                

#exit main;
main ()



>

>
> How do i convert it to python?
> Python i DO have working...
>
> (I did try to mail the author, but i got a bounced mail...)
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.xcf.berkeley.edu
http://lists.xcf.berkeley.edu/mailman/listinfo/gimp-user

Reply via email to