[python-win32] Python COM User Defined Types
Jens B. Jorgensen
jens.jorgensen@tallan.com
Wed, 26 Feb 2003 09:10:29 -0600
Is there any pre-requisite for the Record call (aside from having the
makepy-generated module available)? I tried this and it wouldn't work
for me (UDT defined in VB ActiveX dll):
>>> from win32com.client import Record
>>> from win32com.client import Dispatch
>>> o = Dispatch('udttest.mainclass')
>>> r = Record('TheUDT', o)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python22\Lib\site-packages\win32com\client\__init__.py", line
295, in
Record
struct_guid = module.RecordMap[name]
AttributeError: 'module' object has no attribute 'RecordMap'
>>>
Mark Hammond wrote:
>>How can I create variables in my Python code and use them when calling the
>>WriteMsg2 method (below)?
>>
>>
>
>You would write:
>
> # Create a new structure
> s = win32com.client.Record("StructName", object)
>
>where 'object' is (any) COM object from the library you are using - eg, the
>object with the WriteMsg2 method.
>
>
>
>>Why do I not get a list of
>>available constants when I type "win32com.clients.constants."
>>
>>
>
>These constants are only available once the generated code for the COM
>object has been imported. This is generally done by one of the gencache
>modules, or even by normal "Dispatch()", assuming makepy has been run
>manually. ie, the constants will only be available after the object has
>been created.
>
>
>
>>Typically after
>>entering the period at the end of an object I am presented
>>with a list of attributes/constants/methods.
>>
>>
>
>Clever, eh? <wink>
>
>
>
>>I am concerned by these lines from the file generated by makepy:
>># The following 3 lines may need tweaking for the particular server
>># Candidates are pythoncom.Missing and pythoncom.Empty
>>defaultNamedOptArg=pythoncom.Missing
>>defaultNamedNotOptArg=pythoncom.Missing
>>defaultUnnamedArg=pythoncom.Missing
>>
>>I do not know what to do about the pythoncom.Missing and pythoncom.Empty
>>candidates. What should be done about them?
>>
>>
>
>Ignore them. I should remove the generated comment.
>
>
>
>>Can I simply create an object of type StackObj like this:
>>myStack = StackObj()
>>
>>
>
>Nope - like above.
>
>Mark.
>
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32@python.org
>http://mail.python.org/mailman/listinfo/python-win32
>
>
--
Jens B. Jorgensen
jens.jorgensen@tallan.com
"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"