Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to script an OLE component using Python

I would like to use Python to script an application that advertises itself as providing an OLE component. How should I get started?

I don't yet know what methods I need to call on the COMponents I will be accessing. Should I use win32com to load those components, and then start pressing 'tab' in IPython?

like image 712
joeforker Avatar asked Nov 10 '08 20:11

joeforker


3 Answers

"Python and COM" contains an example. OLE is related to COM and ActiveX so you should look for those terms.

"Python Programming on Win32" is a useful book. There is also a "Python Win32" mailing list.

like image 147
Brian Lyttle Avatar answered Oct 20 '22 02:10

Brian Lyttle


You need the win32com package. Some examples:

from win32com.client.dynamic import Dispatch

# Excel
excel = Dispatch('Excel.Application')

# Vim
vim = Dispatch('Vim.Application')

And then call whatever you like on them.

like image 36
Ali Afshar Avatar answered Oct 20 '22 02:10

Ali Afshar


win32com is a good package to use if you want to use the IDispatch interface to control your objects, but it's slow.

comtypes is a better, native Python, package that uses the raw COM approach to talk to your controls.

WxPython uses comtypes to give you an ActiveX container window from Python.

like image 44
ZebZiggle Avatar answered Oct 20 '22 01:10

ZebZiggle