我想將顏色從這些常量傳遞到下面的設置fontcolor函數,但是每次我都會得到「無法解析顏色名稱」除非我直接從GIMP對話框傳遞它。我甚至直接記錄了正在傳入的變量,來自編號2的值是來自日誌的直接拷貝。任何人都可以看到我在做什麼錯或在這裏失蹤。由於GIMP Python無論我使用什麼格式,我總是會得到「無法解析顏色名稱」
FontGREEN1 = '(RGB(0,255,0,))'
FontGREEN2 = 'RGB (0.0, 1.0, 0.0, 1.0)'
#This causes the error
def setColor1 (txtlayer, color):
color = FontGREEN1
pdb.gimp_text_layer_set_color(txtlayer, color)
#This causes the error
def setColor2 (txtlayer):
color = FontGREEN2
pdb.gimp_text_layer_set_color(txtlayer, color)
#this work fine, color passed directly from GIMP Dialog
def setColor3 (txtlayer, color):
pdb.gimp_text_layer_set_color(txtlayer, color)
def setTextColor (img, drw, color):
txtlayer = img.active_layer
setColor3(txtlayer, color)
register(
'setTextColor',
'Changes the color of the text with python',
'Changes the color of the text with python',
'RS',
'(cc)',
'2014',
'<Image>/File/Change Text Color...',
'', # imagetypes
[
(PF_COLOR,"normal_color","Green Color of the Normal Font",(0,234,0) ),
], # Parameters
[], # Results
setTextColor)
main()
對不起,這是我的一個錯字,在我的原始代碼中是正確的。 – rtsnhth 2014-09-04 08:45:24