微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

查找和使用形状位置 Python pptx

如何解决查找和使用形状位置 Python pptx

我正在尝试定位其中包含特定文本的形状的位置。获得形状的位置后,我想在与打开时突出显示其在 PowerPoint 中的位置相同的位置添加图像。这是我目前所拥有的:

from pptx import Presentation  
from pptx.util import Inches,Pt 

path_map = 'Path/TO.pptx'
prs = Presentation(path_map)
image_file = 'Path/TO.png'
search_str = 'Jack'
for slide in prs.slides:
    for shape in slide.shapes:
        if shape.has_text_frame:
            if(shape.text.find(search_str))!=-1:
                horiz_ = shape.left
                vert_ = shape.top
                height_ = Inches(1)
                width_ = Inches(1) 
                slide.shapes.add_picture(image_file,horiz_,vert_,width_,height_)
prs.save(path_map)

运行时,没有弹出错误,但也没有添加图像,对我缺少的东西有什么建议吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。