日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

用python将图片写入ppt_用python做ppt服务用于导入图片

發布時間:2023/12/10 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用python将图片写入ppt_用python做ppt服务用于导入图片 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目需要做WINFORM程序與powerpoint交互,把winform生成的圖片自動拷貝到ppt中。目前使用python做了一個簡單的服務解決。由于要求是32位程序,所以下面全都是32位的版本。

第一步,安裝python2.7 32位。

第二部,安裝py2exe 32位。

第三步,安裝pywin32 32位。

第四步,用Eclipse(pydev插件)寫代碼,見附件。主要內容如下:

// wavy_ppt_service.pyimport?SocketServer

import?win32com.client

import?sys

class?MyTCPHandler(SocketServer.BaseRequestHandler):

"""

The?RequestHandler?class?for?our?server.

It?is?instantiated?once?per?connection?to?the?server,?and?must

override?the?handle()?method?to?implement?communication?to?the

client.

"""

def?handle(self):

#?self.request?is?the?TCP?socket?connected?to?the?client

self.data?=?self.request.recv(1024).strip()

#????????print?"{}?wrote:".format(self.client_address[0])

#????????print?self.data

#?just?send?back?the?same?data,?but?upper-cased

#????????self.request.sendall(self.data.upper())

Application?=?win32com.client.Dispatch("PowerPoint.Application")

currentSlide?=?Application.ActiveWindow.View.Slide

currentSlide.Shapes.Paste()

HOST,?PORT?=?"localhost",?int(sys.argv[1])

#HOST,?PORT?=?"localhost",?9999

#?Create?the?server,?binding?to?localhost?on?port?9999

server?=?SocketServer.TCPServer((HOST,?PORT),?MyTCPHandler)

#?Activate?the?server;?this?will?keep?running?until?you

#?interrupt?the?program?with?Ctrl-C

server.serve_forever()

就是用客戶端和服務端的方式做的一個服務,服務端接收到數據后會將剪切板的圖片拷貝到ppt中。

打開cmd,調用buildExe32.bat就可以生成dist目錄了,包含著exe 程序。

原文:http://2924037.blog.51cto.com/2914037/1692967

總結

以上是生活随笔為你收集整理的用python将图片写入ppt_用python做ppt服务用于导入图片的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。