Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pythonwin com question

27 views
Skip to first unread message

Sam Schulenburg

unread,
Apr 22, 2000, 3:00:00 AM4/22/00
to sams...@pacbell.net
I have a com object that I can excercise with Visual Basic as such:

Dim WApp as New Winx32Lib.Winx32App ' Get an instance of Winx32App
WApp.ShowDemoBox("This is a demo box") ' Call the client ShowDemoBox()

From Python I try the following which starts the client application and
then timesout with the following error msg:

>>> import win32com.client
>>> MyCLSID = '{1A762221-D8BA-11CF-AFC2-508201C10000}'
>>> WApp = win32com.client.Dispatch(MyCLSID)
Traceback (innermost last):
File "<interactive input>", line 1, in ?
File "D:\Python\win32com\client\__init__.py", line 94, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName
(dispatch,userName,clsctx)
File "D:\Python\win32com\client\dynamic.py", line 66, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "D:\Python\win32com\client\dynamic.py", line 57, in
_GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2146959355, 'Server execution failed', None, None)
>>>

Any help would be appreciated
Samuel W. Schulenburg


Sent via Deja.com http://www.deja.com/
Before you buy.

Mark Hammond

unread,
Apr 22, 2000, 3:00:00 AM4/22/00
to
You could try passing different clsctx values to
win32com.client.Dispatch - my guess is that Python's default isnt quite
the same as VBs...

Let me know if changing this works...

Mark.

"Sam Schulenburg" <sams...@pacbell.net> wrote in message
news:8dqver$l4v$1...@nnrp1.deja.com...

Sam Schulenburg

unread,
Apr 25, 2000, 3:00:00 AM4/25/00
to
In Visual Basic I have the following:
'===============================================
Dim theFrame As Varient
Dim dx as DocFile
Dim ex as New ExpSetup
Dim bRes as Integer

if (ex.Start(dx)) then
While ex.GetParam(EXP_RUNNING,bRes)
DoEvents 'Wait for detector to finish
Wend
dx.GetFrame 1, theFrame 'Retreive one image
end if
'===============================================

In Python I have the equivalent:

from PrincetonInst import * # Get the renamed Makepy file for the
# COM object

theFrame = [] # Set up the Varient
dx = DocFile() # Get the DocFile class
ex = win32com.client.Dispatch(ExpSetup.CLSID)
bRes = 0

if (ex.Start(dx)) then # Start detector scanning for data
While ex.GetParam(EXP_RUNNING,bRes): # Detector is scanning
## DoEvents # Wait for detector to finish, This has no
# equivalent in Pythonwin
s = 1 # This gives the while loop something to do
#### This is where everything falls apart
#### theFrame is not the correct datatype
dx.GetFrame(1,theFrame) # Retreive one image

How do I define the correct Varient type in Python?

Sam Schulenburg

Mark Hammond

unread,
Apr 25, 2000, 3:00:00 AM4/25/00
to
"Sam Schulenburg" <sams...@pacbell.net> wrote in message
news:8e2sfb$r6e$1...@nnrp1.deja.com...

> ## DoEvents # Wait for detector to finish, This has no
> # equivalent in Pythonwin

Actually, you _may_ need to call pythoncom.PumpWaitingMessages() here (and
it can never really hurt :-)

> s = 1 # This gives the while loop something to do
> #### This is where everything falls apart
> #### theFrame is not the correct datatype
> dx.GetFrame(1,theFrame) # Retreive one image
>
> How do I define the correct Varient type in Python?

You shouldnt need to.

Try saying:
theFrame = dx.GetFrame(1)

[Or try passing None as the second param]

And magically it should all work. If it doesnt, look into running
"makepy" over your object and try again. If it still doesnt work, post
the code makepy generated for the GetFrame() method and the specific
traceback you see...

Mark.

0 new messages