On 9/29/2009 12:11 PM, Thomas Heller wrote:
> """
> import logging
> logging.basicConfig(level=logging.INFO)
>
> from comtypes.client import CreateObject
> from comtypes.gen.SpeechLib import ISpVoice, ISpNotifySink
> from comtypes import COMObject
>
> class EventSink(COMObject):
>     _com_interfaces_ = [ISpNotifySink]
>
>     def __init__(self, source):
>         self.source = source
>
>     def Notify(self):
>         print "NOTIFIED"
>
> s = CreateObject("SAPI.SpVoice", interface=ISpVoice)
> s.SetInterest(-1, 0)
> s.SetNotifySink(EventSink(s))
>
> s.speak("The quick brown fox jumps over the lazy dog.", 0)
> """
>
> The code does print quite some "NOTIFIED" lines, but it isn't so easy
> to retrieve the actual events from the source. At least, it's a start.
Hello, all,
     I am so pleased to be on the mail list and hope to be able to 
contribute to the project.
I have enjoyed the benefits of comtypes over other solutions very much 
and had great success on XP + Python 2.5
I am currently working on Windows 7, Python 2.6.5, comtypes 0.6.2. (or 
whatever the latest fetch from CVS was (thank you, Thomas for all your 
hard work).
     My current undertaking is wrapping the SensorAPI - 
http://msdn.microsoft.com/en-us/library/dd318953%28VS.85%29.aspx which 
does not have an associated typelib (yet?) and does not support 
TypeInfo.  I generated most of the components from the sibling 
LocationAPI and have hand written the rest of the interface.  I am 
currenly implementing the SensorDevKitDiagnosticApp in wxPython.
     When it came time to hook up the events, I was making good guesses 
(subclassed COMObject), but might have never guess at the 
_com_interfaces_ attribute.  I noticed as I write this that you don't 
keep a reference to the sink object.  For some reason I still get:

DEBUG:comtypes._comobject:Remaining: [<__main__.AccelerometerEventSink 
object at 0x02977450>, <__main__.TouchEventSink object at 0x029E1CF0>, 
<__main__.TouchEventSink object at 0x02977510>]

I'm wondering if I need to make sure that all COM objects are properly 
Release()'d???  These objects hold a reference to the wx.EventHandler 
that will end up receiving the event.  Perhaps they need a __del__(self) 
method or something???

Thomas, I've mailed you directly in case the list bounces me out for 
some reason
(like I'm using the wrong email account or I can't figure out how send 
plain text from Thunderbird).
Thank you,
Barton


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to