Hi there, Am I being stupid somewhere here? I have a class defined (code below) which has a property which is get and put. Here is a sample session of using it:
>>> slice.Value u'18.000000' >>> slice.Value = "19.0" Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:\Python24\lib\site-packages\win32com\client\__init__.py", line 462, in __setattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '<win32com.gen_py.Panorama: Scripting Library (Kernel Objects).IPanScriptTFOSlice instance at 0x11496344>' object has no attribute 'Value' >>> slice.SetValue Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:\Python24\lib\site-packages\win32com\client\__init__.py", line 454, in __getattr__ raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) AttributeError: '<win32com.gen_py.Panorama: Scripting Library (Kernel Objects).IPanScriptTFOSlice instance at 0x11496344>' object has no attribute 'SetValue' Is it possible to set string properties? If so, what am I doing wrong? Thanks for your help! Cheers, Ben class IPanScriptTFOSlice2(DispatchBaseClass): """PanScript TFO Slice.""" CLSID = IID('{6BA870D0-055A-11D4-ABE3-00C04F9D382F}') coclass_clsid = IID('{0E362F40-0587-11D4-ABE3-00C04F9D382F}') # Result is of type IPanScriptTFOSlice # The method Slice is actually a property, but must be used as a method to correctly pass the arguments def Slice(self, Index=defaultNamedNotOptArg): """Gets a slice by setting the first of the remaining dimensions.""" ret = self._oleobj_.InvokeTypes(5, LCID, 2, (9, 0), ((8, 1),),Index ) if ret is not None: ret = Dispatch(ret, 'Slice', '{BFD8D300-8F81-11D2-A508-00C04F718866}', UnicodeToString=0) return ret # Result is of type IPanScriptTFOSlice # The method _Default is actually a property, but must be used as a method to correctly pass the arguments def _Default(self, Index=defaultNamedNotOptArg): """Default action. Gets a slice by setting the first of the remaining dimensions.""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((8, 1),),Index ) if ret is not None: ret = Dispatch(ret, '_Default', '{BFD8D300-8F81-11D2-A508-00C04F718866}', UnicodeToString=0) return ret _prop_map_get_ = { # Method 'Application' returns object of type 'IPanScriptApplication' "Application": (1, 2, (9, 0), (), "Application", '{70C0547D-32CF-11D2-AA93-00C04FA2F3C6}'), "CouldHaveValue": (8, 2, (11, 0), (), "CouldHaveValue", None), "DimensionOrdinal": (10, 2, (3, 0), (), "DimensionOrdinal", None), # Method 'Dimensions' returns object of type 'IPanScriptTFODimensions' "Dimensions": (4, 2, (9, 0), (), "Dimensions", '{8BB8A200-85F5-11D2-A507-00C04F718866}'), "HasValue": (7, 2, (11, 0), (), "HasValue", None), "Name": (3, 2, (8, 0), (), "Name", None), "Parent": (2, 2, (9, 0), (), "Parent", None), # Method 'ParentSlice' returns object of type 'IPanScriptTFOSlice' "ParentSlice": (9, 2, (9, 0), (), "ParentSlice", '{BFD8D300-8F81-11D2-A508-00C04F718866}'), "Value": (6, 2, (12, 0), (), "Value", None), } _prop_map_put_ = { "Value": ((6, LCID, 4, 0),()), } # Default method for this class is '_Default' def __call__(self, Index=defaultNamedNotOptArg): """Default action. Gets a slice by setting the first of the remaining dimensions.""" ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((8, 1),),Index ) if ret is not None: ret = Dispatch(ret, '__call__', '{BFD8D300-8F81-11D2-A508-00C04F718866}', UnicodeToString=0) return ret # str(ob) and int(ob) will use __call__ def __unicode__(self, *args): try: return unicode(self.__call__(*args)) except pythoncom.com_error: return repr(self) def __str__(self, *args): return str(self.__unicode__(*args)) def __int__(self, *args): return int(self.__call__(*args)) def __iter__(self): "Return a Python iterator for this object" ob = self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()) return win32com.client.util.Iterator(ob) def _NewEnum(self): "Create an enumerator from this object" return win32com.client.util.WrapEnum(self._oleobj_.InvokeTypes(-4,LCID,2,(13, 10),()),None) def __getitem__(self, index): "Allow this class to be accessed as a collection" if not self.__dict__.has_key('_enum_'): self.__dict__['_enum_'] = self._NewEnum() return self._enum_.__getitem__(index) Ben Young - Software Engineer SunGard - Enterprise House, Vision Park, Histon, Cambridge, CB4 9ZR Tel +44 1223 266049 - Main +44 1223 266000 - http://www.sungard.com/ CONFIDENTIALITY: This email (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this email in error, please notify the sender and delete this email from your system. Thank you. _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32