|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Name completion on .NET and COM objectsHi.
We're currently evaluating Wing IDE Professional 3.1.4-1 (rev 18789), and so far it seems as a big step up from old Pythonwin. I have an issue with name completion on COM (win32com) and .NET (Pythonnet) objects. Completion works on Pythonwin but not on Wing. While Pythonwin lists all available attributes on these objects, Wing only shows the COM attributes i.e not the COM objects own attributes. Same applies to .NET object. Ex. for COM late binding: >>> >>> import win32com.client >>> excel = win32com.client.Dispatch("Excel.Application") >>> >>> # Pythonwin lists all available attributes when >>> # hitting the "." after "excel" >>> # <here> >>> # | >>> # v >>> excel.Application() >>> >>> # Using Wing you only get what seems to be COM low-level stuff. Ex. .NET through Pythonnet >>> >>> import clr >>> import System >>> # Pythonwin lets us e.g select Math and PI. >>> # Wing displays nothin... >>> System.Math.PI 3.1415926535897931 >>> NOTE: Its only the name completion that fails in Wing. Typing for instance "System.Math.PI" as above, returns the magic number PI from .NET. Is this an unsupported and never gonna support feature in Wing, or have I just failed to setup Wing correct? Greatful for any input. Thanks! /Sven _________________________________________________ Wing IDE users list http://wingware.com/lists/wingide |
|
|
Re: Name completion on .NET and COM objectsWikström Sven wrote:
> I have an issue with name completion on COM (win32com) and .NET (Pythonnet) objects. Completion works on Pythonwin but not on Wing. While Pythonwin lists all available attributes on these objects, Wing only shows the COM attributes i.e not the COM objects own attributes. Same applies to .NET object. > > Ex. for COM late binding: >>>> import win32com.client >>>> excel = win32com.client.Dispatch("Excel.Application") >>>> >>>> # Pythonwin lists all available attributes when >>>> # hitting the "." after "excel" >>>> # <here> >>>> # | >>>> # v >>>> excel.Application() > u'Microsoft Excel' >>>> # Using Wing you only get what seems to be COM low-level stuff. > > Ex. .NET through Pythonnet >>>> import clr >>>> import System >>>> # Pythonwin lets us e.g select Math and PI. >>>> # Wing displays nothin... >>>> System.Math.PI > 3.1415926535897931 Is this in the editor or in either the interactive shell or debug probe? It should work in the shell or probe, but it won't work in the editor because the editor relies on static analysis. Thanks, John _________________________________________________ Wing IDE users list http://wingware.com/lists/wingide |
|
|
RE: Name completion on .NET and COM objectsHi.
Thanks for the response. I understand that it cannot work in the main editor window. But it does not work in the interactive shell nor the probe either, for me at least. Behaviour in Wings interactive shell: >>>> import win32com.client >>>> excel = win32com.client.Dispatch("Excel.Application") >>>> excel.XXXXXX Where "XXXXXX" is just a completion list of low-level COM stuff. I do not get name completion for the actual Excel COM object's attributes as with Pythonwin. Do I need a special setup? We would love to use Wing as it seems to be THE Python editor. We deal with COM and .NET quite a lot so this is the last question mark. Thanks again! /Sven -----Original Message----- From: Wingware Support [mailto:support@...] Sent: den 10 oktober 2008 17:52 To: Wikström Sven Cc: wingide-users@... Subject: Re: [wingide-users] Name completion on .NET and COM objects Wikström Sven wrote: > I have an issue with name completion on COM (win32com) and .NET > (Pythonnet) objects. Completion works on Pythonwin but not on Wing. > While Pythonwin lists all available attributes on these objects, Wing > only shows the COM attributes i.e not the COM objects own attributes. > Same applies to .NET object. > > Ex. for COM late binding: >>>> import win32com.client >>>> excel = win32com.client.Dispatch("Excel.Application") >>>> >>>> # Pythonwin lists all available attributes when >>>> # hitting the "." after "excel" >>>> # <here> >>>> # | >>>> # v >>>> excel.Application() > u'Microsoft Excel' >>>> # Using Wing you only get what seems to be COM low-level stuff. > > Ex. .NET through Pythonnet >>>> import clr >>>> import System >>>> # Pythonwin lets us e.g select Math and PI. >>>> # Wing displays nothin... >>>> System.Math.PI > 3.1415926535897931 Is this in the editor or in either the interactive shell or debug probe? It should work in the shell or probe, but it won't work in the editor because the editor relies on static analysis. Thanks, John _________________________________________________ Wing IDE users list http://wingware.com/lists/wingide |
|
|
Re: Name completion on .NET and COM objectsWikström Sven wrote:
> Thanks for the response. > > I understand that it cannot work in the main editor window. > But it does not work in the interactive shell nor the probe either, for me at least. > > Behaviour in Wings interactive shell: >>>>> import win32com.client >>>>> excel = win32com.client.Dispatch("Excel.Application") >>>>> excel.XXXXXX > > Where "XXXXXX" is just a completion list of low-level COM stuff. I do not get name completion for the actual Excel COM object's attributes as with Pythonwin. > > Do I need a special setup? > > We would love to use Wing as it seems to be THE Python editor. We deal with COM and .NET quite a lot so this is the last question mark. From reading the win32com sources, it looks like the Dispatch class does things entirely via a __call__ method, and that doesn't ever add the methods/etc for the wrapped class to the wrapper, so even at runtime in the Debug Probe or Python Shell it's not possible for Wing to determine what the methods should be. I'm fairly sure that PythonWin must contain some special code to handle these. I haven't found the code there yet but it may just introspect the COM classes directly. Wing isn't set up to special case these. One way to work around this would be to generate *.py skeletons for the COM objects you're using, store them on disk and create a wrapper for each creation that is something like this: def CreateExcelApplication(): retval = win32com.client.Dispatch("Excel.Application") import excel_application_skeleton isinstance(retval, excel_application_skeleton.ExcelApplication) return retval Then at point of use do the following instead of calling Dispatch directly: excel = CreateExcelApplication() You'll should get both the names in the wrapper and the skeleton when you do 'excel.' We're planning on trying to make this kind of thing possible in the future w/o altering code, but for now the above is the way to handle this case. Please let me know if you run into any problems with it, or there's something I need to clarify. Thanks, -- Stephan Deibel Wingware | Python IDE Advancing Software Development www.wingware.com _________________________________________________ Wing IDE users list http://wingware.com/lists/wingide |
| Free Forum Powered by Nabble | Forum Help |