Controlling Powerpoint using Leap motion and Python

寵の児 提交于 2019-12-10 11:33:23

问题


I just started up with python.I lately got a project where I have to make a powerpoint slideshow.This has to be done using leap motion sdk and python.So my powerpoint will be gesture based.

  1. How do I deploy this on my desktop in such a away that I just need to click on my desktop app or the ppt file itself, I get started with the powerpoint like on windows.
  2. I need to detect the finger gestures using python and integrate it to next - previous functionality.

Can I get some guidance on powerpoint with PPT?

I have got the API,Documentation,SDK and I am learning python too.


回答1:


The pywin32 library has a win32com.client module that lets you use COM API to control PowerPoint.

For example, this code will add a slide with an oval in it:

import win32com.client

Application = win32com.client.Dispatch("PowerPoint.Application")
Presentation = Application.Presentations.Add()
Base = Presentation.Slides.Add(1, 12)
oval = Base.Shapes.AddShape(9, 100, 100, 100, 100)

This IPython notebook has step-by-step examples on how to create a PowerPoint presentation, add objects to it, and make those objects interact in PowerPoint.

While this will allow you to use PowerPoint as an output interface, you need a different mechanism for sending messages back from PowerPoint to Python. One way is to set up a Macro that runs on a click event that interacts with a COM server set up in Python.




回答2:


The documentation for this is not fantastic. However, using win32com and the PowerPoint API, you should be able to accomplish what you want to do.

The relevant commands are:

import win32com.client
import time

app = win32com.client.Dispatch("PowerPoint.Application")
presentation = app.Presentations.Open(FileName=u'C:\\path\\to\\mypresenation.pptx', ReadOnly=1)

presentation.SlideShowSettings.Run()

time.sleep(1)
presentation.SlideShowWindow.View.Next()
time.sleep(1)
presentation.SlideShowWindow.View.Next()
time.sleep(1)
presentation.SlideShowWindow.View.Previous()
time.sleep(1)

presentation.SlideShowWindow.View.Exit()

app.Quit()

Once you have a reference to the presentation, you can use this inside the code/functions where you handle the gestures.




回答3:


you can some some pointers on what you want to do from this guy https://github.com/sanand0 look at his https://github.com/sanand0/pptx-git repo you should definitely get some pointers.

Hope this helps



来源:https://stackoverflow.com/questions/18670428/controlling-powerpoint-using-leap-motion-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!