2016-07-05 2 views
0
def new_presentation(): 
    prs=Presentation() 
    img="C:/Users/Dennis/Desktop/Tom-Hiddleston-4-1024x768.jpg" 
    mainsld=new_slide(prs, 6) 
    mainshp=mainsld.shapes 
    mainshp.add_picture(img, 0,0, Inches(10)) 
    titleshape=mainshp.add_shape(MSO_SHAPE.RECTANGLE, Inches(0), Inches(1), Inches(10), Inches(1)) 
    titleshape.fill.solid() 
    titleshape.fill.fore_color.rgb=RGBColor(0x00,0x64,0x00) 
    titleshape.fill.transparency = 0.25 ##doesnt work???########################## 
    titleshape.line.fill.background() 
    titlebox=mainshp.add_textbox(Inches(1), Inches(0.8),Inches(1), Inches(1)).text_frame.add_paragraph() 
    titlebox.text="TOM HIDDLESTON" 
    titlebox.font.name="Calibri" 
    titlebox.font.size=Pt(36) 
    titlebox.font.color.rgb=RGBColor(0x90,0x90,0x00) 
    prs.save('test.pptx') 

"###### s"로 표시된 줄은 pptx 설명서에 설명 된대로 모양을 투명하게 만들어야합니다.이 줄은 shape.fill 속성입니다. 코드의 다른 모든 것이 완벽하게 작동합니다. 파이썬 2.7 및 최신 pptx 사용하고 있습니다. 사전에 도움을 주셔서 감사합니다.python pptx에서 모양을 투명하게 추가하려면 어떻게해야합니까?

답변

0

FillFormat.transparency은 아직 구현되지 않았습니다. 당신이 보았던 문서의 부분은 개발의 선구자 인 분석 페이지일지도 모른다.

는 분석 페이지입니다 : http://python-pptx.readthedocs.io/en/latest/dev/analysis/features/dml-fill.html?highlight=transparency

이것은 FillFormat (.fill) API는 개발로 : 당신은 그러나 아래의 XML을 조작 할 FillFormat 객체에서 호출을 LXML 사용할 수 있습니다 http://python-pptx.readthedocs.io/en/latest/api/dml.html#fillformat-objects

그것. 당신의 다양한 조합에 검색 할 경우 당신은 더 찾을 수 https://groups.google.com/forum/#!msg/python-pptx/UTkdemIZICw/qeUJEyKEAQAJ

:

spPr = titleshape.fill._xPr 
print spPr.xml 

여기에 그런 일을하는 하나의 예입니다 : 당신은 아마 .fill 요소에 및 nvSpPr 요소 시작하려면 용어는 python-pptx, OxmlElement, lxmlworkaround function입니다.

관련 문제