2016-01-24 46 views
6

私はgimp python-fuプログラミングの新人です 私は4日間を無駄なく使い、描画されたパスの座標を取得し、gtkメッセージボックスのような出力を表示するのに最適な関数を見つけました以下の画像。Gimp:パスツールポイントの座標はどのように取得できますか?

enter image description here

私はこのように私のコードを試してみましたが、Windowsマシン

上で開発することを検討してください:

import gtk, gimpui 
from gimpfu import * 

def debugMessage(Message): 
    dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, Message) 
    dialog.run() 
    dialog.hide() 

def python_fu_mahdicoordinates(image, layer): 
    vectors = pdb.gimp_image_get_active_vectors(image) 
    nstrokes, strokes = pdb.gimp_vectors_get_strokes(vectors) 
    stroke_type, n_points, cpoints, closed = pdb.gimp_vectors_stroke_get_points(vectors, strokes[0]) 
    x0 = cpoints[0] 
    y0 = cpoints[1] 
    x1 = cpoints[6] 
    y1 = cpoints[7] 
    x2 = cpoints[12] 
    y2 = cpoints[13] 
    x3 = cpoints[18] 
    y3 = cpoints[19] 
    debugMessage('(' + str(x0) + ', ' + str(y0) + ', '+str(x1) + ', '+str(y1) + ', '+str(x2) + ', '+str(y2) + ', '+str(x3) + ', '+str(y3) + ')') 

    return 

register(
    "python_fu_mahdicoordinates", 
    "Mahdi Cooridnates", 
    "Get Cooridnates of any path", 
    "Mahdi Alkhatib", "Mahdi Alkhatib", "2016", 
    "Mahdi Cooridnates...", 
    "*", 
    [], 
    [], 
    python_fu_mahdicoordinates, 
    menu= "<Image>/Tools/Misc") 

main() 

時々、プラグイン自体は時々出力なし、メニューには表示されません。まったく。

答えて

2

私はUbuntuでこの問題をテストしています(これは同じではないことは分かっています)。しかし、あなたのコードは何も出力していないので、私は少なくともこの問題の部分を再現することができました。

あなたの関数は、この宣言ヘッダー持っている:だから

def python_fu_mahdicoordinates(image, layer): 

を、registerはこのように呼ばれるべき:変更されたリストで

register(
    "python_fu_mahdicoordinates", 
    "Mahdi Cooridnates", 
    "Get Cooridnates of any path", 
    "Mahdi Alkhatib", "Mahdi Alkhatib", "2016", 
    "Mahdi Cooridnates...", 
    "*", 
    [ 
     (PF_IMAGE, "image", "takes current image", None), 
     (PF_LAYER, "layer", "takes current layer", None), 
    ], 
    [], 
    python_fu_mahdicoordinates, 
    menu= "<Image>/YourNewMenu") 

、あなたの関数を宣言する必要が処理する必要があるパラメータ。あなたの場合、画像とレイヤー。これは私のために働く。

あなたのメニューにプラグインが表示されない理由はわかりませんが、好きな名前でmenu= "<Image>/YourNewMenu"と宣言してみてください。これにより、メニューバーに新しいメニューが生成され、おそらく完全にあなたの問題が解決されます。試してみる価値があります。

こちらがお役に立てば幸いです。

関連する問題