473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

python and COM

Hello,

I am trying to communicate to a Reuters feed using Python, using a particular set of
libraries called the Adfin Real Time library. I have VB code, and am trying to port
it to python, and admit I really do not understand COM objects and being a Linux guy
mainly, I don't use VB at all. I've had some marginal success, but am coming up
empty when it comes to setting up callbacks.

For example, this works:

import win32com.client
import time

symb='GOOG.O'

mylist=win32com.client.Dispatch('AdfinXRTLib.AdxRt List')

mylist.Source="IDN_RDF"
mylist.RegisterItems(symb,"ASK")
mylist.StartUpdates(4) # Mode Image

while mylist.ItemStatus(symb):
pass

for i in range(100):
m=mylist.Value(symb,"ASK")
print m
time.sleep(2)
but to get it to automatically updated quotes, in VB they do something like

#================
Public Class Form1
# Dimension a Public Real Time list object that is capable of handling events
# note from me: not sure what this line does really
Dim WithEvents AdxList As New AdfinXRTLib.AdxRTList

Public Sub AdxList_OnUpdate( <some args deleted>) Handles AdxList.OnUpdate

do stuff with the updated data

End Sub

Private Sub Button1_Click(<some args deleted>)

do stuff with button click
End Sub
End Class
#================

It seems as if the important part is the "Handles AdxList.OnUpdate", which I assume
is basically saying "call me when AdxList.OnUpdate is called". I have no idea how to
get this to point to a python function, so I can make the AdxList.OnUpdate call
python code.

Is there a tutorial somewhere about this stuff, or is there a proper place to ask
such questions?
thanks,
Brian Blais

--
-----------------

bb****@bryant.edu
http://web.bryant.edu/~bblais
Apr 27 '07 #1
2 1913
On Apr 27, 2:50 pm, Brian Blais <bbl...@bryant.eduwrote:
Hello,

I am trying to communicate to a Reuters feed using Python, using a particular set of
libraries called the Adfin Real Time library. I have VB code, and am trying to port
it to python, and admit I really do not understand COM objects and being a Linux guy
mainly, I don't use VB at all. I've had some marginal success, but am coming up
empty when it comes to setting up callbacks.

For example, this works:

import win32com.client
import time

symb='GOOG.O'

mylist=win32com.client.Dispatch('AdfinXRTLib.AdxRt List')

mylist.Source="IDN_RDF"
mylist.RegisterItems(symb,"ASK")
mylist.StartUpdates(4) # Mode Image

while mylist.ItemStatus(symb):
pass

for i in range(100):
m=mylist.Value(symb,"ASK")
print m
time.sleep(2)

but to get it to automatically updated quotes, in VB they do something like

#================
Public Class Form1
# Dimension a Public Real Time list object that is capable of handling events
# note from me: not sure what this line does really
Dim WithEvents AdxList As New AdfinXRTLib.AdxRTList

Public Sub AdxList_OnUpdate( <some args deleted>) Handles AdxList.OnUpdate

do stuff with the updated data

End Sub

Private Sub Button1_Click(<some args deleted>)

do stuff with button click
End Sub
End Class
#================

It seems as if the important part is the "Handles AdxList.OnUpdate", which I assume
is basically saying "call me when AdxList.OnUpdate is called". I have no idea how to
get this to point to a python function, so I can make the AdxList.OnUpdate call
python code.

Is there a tutorial somewhere about this stuff, or is there a proper place to ask
such questions?

thanks,

Brian Blais

--
-----------------

bbl...@bryant.edu
http://web.bryant.edu/~bblais
I found some info on Python, VB, and COM. Check out the links below:

http://vb2py.sourceforge.net/
http://mail.python.org/pipermail/pyt...ly/332502.html
http://www.oreilly.com/catalog/pytho...pter/ch12.html
http://mail.python.org/pipermail/mel...il/000132.html

Not sure if those will help, but they might give you some food for
thought.

Mike

Apr 27 '07 #2
Brian Blais wrote:
Hello,

I am trying to communicate to a Reuters feed using Python, using a
particular set of libraries called the Adfin Real Time library. I have
VB code, and am trying to port it to python, and admit I really do not
understand COM objects and being a Linux guy mainly, I don't use VB at
all. I've had some marginal success, but am coming up empty when it
comes to setting up callbacks.

For example, this works:

import win32com.client
import time

symb='GOOG.O'

mylist=win32com.client.Dispatch('AdfinXRTLib.AdxRt List')

mylist.Source="IDN_RDF"
mylist.RegisterItems(symb,"ASK")
mylist.StartUpdates(4) # Mode Image

while mylist.ItemStatus(symb):
pass

for i in range(100):
m=mylist.Value(symb,"ASK")
print m
time.sleep(2)
but to get it to automatically updated quotes, in VB they do something like

#================
Public Class Form1
# Dimension a Public Real Time list object that is capable of handling
events
# note from me: not sure what this line does really
Dim WithEvents AdxList As New AdfinXRTLib.AdxRTList

Public Sub AdxList_OnUpdate( <some args deleted>) Handles
AdxList.OnUpdate

do stuff with the updated data

End Sub

Private Sub Button1_Click(<some args deleted>)

do stuff with button click
End Sub
End Class
#================

It seems as if the important part is the "Handles AdxList.OnUpdate",
which I assume is basically saying "call me when AdxList.OnUpdate is
called". I have no idea how to get this to point to a python function,
so I can make the AdxList.OnUpdate call python code.

Is there a tutorial somewhere about this stuff, or is there a proper
place to ask such questions?
thanks,
Brian Blais
It looks like you are correct. This is a callback function that gets
called when the update occurs. The only coverage of this I've found is
in "Python Programming on Win32" but it is rather brief even there. I
have not any event driven callbacks, so I can't help all that much.
Normally you define a Python class that has methods that ADxList.OnUpdate
is expecting to be able to call. Then depending on implementation you
either call it with an instance of that class or you may have to wrap
the instance in a COM IDispatch object by calling win32com.server.util.wrap()
around an instance of the function. Sorry I can't be more helpful.

-Larry
Apr 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.