Autocomplete for PythonWin Makepy COM wrappers

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Autocomplete for PythonWin Makepy COM wrappers

WingIDE - User mailing list
Hi folks,

I'm wondering is there's some additional think I need to do to get autocomplete to work completely when using COM Library wrapper modules produced by PythonWin Makepy. This would make interacting with MS Office products far more pleasant.

The problem seems to be that many members of objects in eg: Excel are not direct members from a COM wrapper perspective. So for example:

=================================
1  import win32com
2  import excel140_64 as Excel
3
4  excel = win32com.client.GetActiveObject('Excel.Application') # type: Excel._Application  
5  wbs = excel.Workbooks # type: Excel.Workbooks
6  wb = wbs.Add() # type: Excel._Workbook
7  name = wb.Name
=================================

This code works, but the autocomplete only partially works.

1. It's necessary to use the underscore versions of  Application and Workbook in lines 4 and 6, because the plain classes are defined in the makepy object library wrapper like this:

=========================================
class Application(CoClassBaseClass):
[...]
        coclass_interfaces = [
                _Application,
        ]
        default_interface = _Application
=========================================

... and it's in _Application that many methods are declared. Not fatal, you just have to know to use the underscore version for type hinting.

2. More seriously, many such classes have a large number of properties declared in member _prop_map_get = {...} and _prop_map_put_ = {...}, and these don't seem to be seen by IDE autocomplete at all -- at least I don't know how to get them to work.

So, in the current example, lines 5 and 7, though they offer legit autocomplete suggestions, those suggestions don't include a large proportion of the possible members, including the ones used here (excel.Workbooks and wb.Name).

Ideas?  Thanks!

Graham



_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide
Reply | Threaded
Open this post in threaded view
|

Re: Autocomplete for PythonWin Makepy COM wrappers

WingIDE - User mailing list
Graham Wideman via wingide-users wrote:
> I'm wondering is there's some additional think I need to do to get autocomplete to work completely when using COM Library wrapper modules produced by PythonWin Makepy. This would make interacting with MS Office products far more pleasant.

These wrappers do various things that make static analysis difficult,
unless we were to special case them.  The general solution for such
cases is to run to a breakpoint and work in the live runtime state.  The
auto-completer should then include the complete list of symbols because
it inspects the runtime.

Please let me know if that doesn't help.

Thanks,

--

Stephan Deibel
Wingware | Python IDE

The Intelligent Development Environment for Python Programmers

wingware.com


_________________________________________________
Wing IDE users list
http://wingware.com/lists/wingide