[python-win32] translating VB into Python...

Graham Bloice graham.bloice at trihedral.com
Wed May 16 16:53:17 CEST 2007


Tim Golden wrote:
> Michael March wrote:
>> [resend - I think the mailing list ate my last post..]
> 
> I saw it! But no matter, the web link's useful. I imagine
> Mark's hitting the sack about now (assuming he's in
> Australia). It's 3pm here in the UK so I'll try to see
> if I can spot what's happening, but from a glance at
> the generated code, it looks like one of those awkward
> cases where a method is also a property and *also* the
> default value. I'll try and have a go at it.
> 

Looking at the makepy output isn't this a case where pywin32 has to use
a method to access an indexed property using a "SetXXX" call.

>From the makepy:

class IBug(DispatchBaseClass):
	"""Represents a defect."""
	CLSID = IID('{2AF970F7-6CCC-4DFB-AA78-08F689481F94}')
	coclass_clsid = IID('{AF9180F9-8C16-4824-9EA1-A9010B072B2C}')

	# The method Field is actually a property, but must be used as a method
to correctly pass the arguments
	def Field(self, FieldName=defaultNamedNotOptArg):
		"""The value of the specified field."""
		return self._ApplyTypes_(0, 2, (12, 0), ((8, 0),), 					'Field',
None,FieldName)

...

	# The method SetField is actually a property, but must be used as a
method to correctly pass the arguments
	def SetField(self, FieldName=defaultNamedNotOptArg, 					
arg1=defaultUnnamedArg):
		"""The value of the specified field."""
		return self._oleobj_.InvokeTypes(0, LCID, 4, (24, 0), 					((8, 0),
(12, 1)),FieldName, arg1)


So try using:

mybug.SetField("BG_DESCRIPTION", "123")

-- 
Regards,

Graham Bloice


More information about the Python-win32 mailing list