From: Thomas H. <th...@ct...> - 2009-02-19 20:42:07
|
[I added comtypes-users to the list of recipients, in case any existing comtypes users is interested in this] Amaury Forgeot d'Arc schrieb: > Hello Thomas, hello to all pypy-ers, > > I'm sure you will be interested to know that the ctypes implementation of pypy > has matured enough to be able to run the comtypes module, > at least some of the examples I found on the web site: > http://starship.python.net/crew/theller/comtypes/ > See the copy of a pypy session below. Really cool to hear this. I must say that I sometimes look over the commit messages in the pypy.cvs mailing list (via gmane) and I'm fascinated by the work with ctypes that is done there! What I fear is that the day is not far where you know much more than myself about ctypes ;-) > Not everything works, though. > For example, the COMError exception does not give any message, > some errors are caused by the alternate garbage collector of pypy > (opposed to the determinism of reference counting), > and I'm sure that I missed many important details... > At least it is now possible to run the comtypes test suite: some tests > even pass ;-) > > Hey, I did not know that ctypes and comtypes where so intricate: > ctypes obviously has features designed for comtypes only (OUT parameters...) > and ctypes/__init__.py even tries to import comtypes.server.inprocserver! > > But this was all fun, and I learned a lot about ffi and COM from > reading the code. > Thanks for these wonderful modules! > > > > Python 2.5.2 (61966, Feb 17 2009, 13:39:17) > [PyPy 1.0.0] on win32 > Type "help", "copyright", "credits" or "license" for more information. > And now for something completely different: ``who am I and if yes, how many?'' >>>>> from comtypes.client import CreateObject >>>>> xl = CreateObject("Excel.Application") > # Generating comtypes.gen._00020813_0000_0000_C000_000000000046_0_1_3 > # Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0 > # Generating comtypes.gen.stdole > # Generating comtypes.gen._2DF8D04C_5BFA_101B_BDE5_00AA0044DE52_0_2_1 > # Generating comtypes.gen.Office > # Generating comtypes.gen._0002E157_0000_0000_C000_000000000046_0_5_3 > # Generating comtypes.gen.VBIDE > # Generating comtypes.gen.Excel >>>>> xl.Workbooks.Add() > <POINTER(_Workbook) ptr=0x16af6c at 35> >>>>> xl.Range("E1").Formula = "=SUM(A1:D1)" >>>>> print xl.Range("E1").Value > 0.0 >>>>> xl.Range("A1", "D1").Value = ("Data", 10, 20, 30) >>>>> print xl.Range("E1").Value > 60.0 >>>>> xl.Visible = True >>>>> > > Cheers, > Fantastic! I wish I had time to use pypy or even participate, but there is no chance, unfortunately. -- Thanks, Thomas |