[python-win32] Trying to implement an third-party interface in COM for events

Kapil fadnis kfadnis at gmail.com
Mon Apr 13 19:38:13 CEST 2009


Quick follow-up question, you mention threading in the post and how it might
hinder some of the messaging. Could this be a potential problem since in the
C# or MFC application there is essentially a mainloop which is a perpetual
loop ? There is no such thing in the implementation below, and thus does not
fire events.

On Mon, Apr 13, 2009 at 3:09 AM, Mark Hammond <skippy.hammond at gmail.com>wrote:

>  On 11/04/2009 4:26 AM, Kapil fadnis wrote:
>
>> I think this has been talked about on a previous thread but its an old
>> thread here but I am hoping to get some feedback that will help me
>> understand the issue,
>>
>> http://mail.python.org/pipermail/python-win32/2006-September/005044.html
>>
>>
>> I have an interface
>> MBTQUOTELib.
>> IMbtQuotesNotify
>> which has four methods to be implemented, each of which is an event on
>> the server side i.e. my broker.
>> One of the methods is "OnQuoteData(QUOTERECORD). The way I have seen it
>> being implemented (in the thread above) is
>> run makepy - i on the interface definition, i use PythonWin for this
>> which gives me a .py file.
>> 13F76618-D199-4485-8C95-DC524958686Cx0x2x0.py
>>
>> The implementation is
>>
>> -------------------------------------------------------------------------------------------
>> from win32com import universal
>>
>> universal.RegisterInterfaces('{13F76618-D199-4485-8C95-DC524958686C}',0,2,0,["IMbtQuotesNotify"])
>> class Q:
>>     _com_interfaces_ = ['IMbtQuotesNotify']
>>     _typelib_guid_ = '{13F76618-D199-4485-8C95-DC524958686C}'
>>     _typelib_version_ = 2, 0
>>
>>     def OnQuoteData(self,pQuote):
>>         print "got onquote!"
>>         print type(pQuote)
>>         print "%s" % pQuote
>>
>> import win32com.server.util
>> qnotify = win32com.server.util.wrap(Q(),useDispatcher=1)
>>
>> import win32com.client as com
>> mbtCom = com.Dispatch("MBTrading.MbtComMgr")
>> mbtCom.DoLogin(9,"myusername","mypassword","")
>> quote = mbtCom.Quotes
>> quote.AdviseSymbol(qnotify,'AAPL',1)
>>
>
> See if adding a call to pythoncom.PumpMessages() at the very end makes a
> difference...
>
> Cheers,
>
> Mark
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20090413/d05787c7/attachment.htm>


More information about the python-win32 mailing list