[wingide-users] Re: Using Wing IDE with IronPython - autocomplete for .NET objects (PI file generator)

Michael Foord fuzzyman at voidspace.org.uk
Thu Apr 30 13:53:07 MDT 2009


Jimmie Houchin wrote:
> Michael Foord wrote:
>> Jimmie Houchin wrote:
>>> This sounds great. I am new to both IronPython, WingIDE and Windows 
>>> development in general.
>>>
>>> One of the disappointing things with WingIDE for me is the total 
>>> absence of autocompletion of .NET imports 
>>
>> Which is what my script provides. The autocomplete for .NET now in 
>> Wing is pretty awesome. Once I've added method return type hints it 
>> will be even better.
>>
>>> and also the DLL Assembly References I've added to access the 
>>> libraries my app requires.
>>
>> What do you mean by this?
>>
>> The *correct* way to do this with IronPython is by calling 
>> clr.AddReference yourself.
>
> Yes, I understand.
>
> In my Python script which I am editing in WingIDE I have:
>
> import clr
> clr.AddReferenceToFile('interop.mylibrary.dll')
> import interop.mylibrary as mylibrary
>
> mylibrary.AutoCompleteDoesNotHappenHere
>
> actually this also is true:
>
> clr.AutoCompleteDoesNotHappenHere
>
> All of the above works great in the IronPython interpreter shell.


Right - if you are using the script I posted then it *only* generates 
the PI files for the assemblies / namespaces specified in the very last 
part of the script.

Modifying it to add the 'clr' module is very easy (I've already done it 
in my copy).

After these lines:

      import clr
      for entry in modnames:
        clr.AddReference(entry)
        __import__(entry)

Add the following line:

  modnames.append('clr')

You will also have to modify the script to generate PI files for the 
custom assemblies you use. Wing doesn't know about the contents of 
assemblies - the PI files are how you tell it what types (etc) are in 
custom assemblies.

If the assembly names and the top level namespaces are the same then you 
can just add the assembly name to the 'modnames' list before it adds 
references to all the assemblies it is generating PI files for. This is 
the line:

  modnames = ['System', 'System.Data', 'System.Windows.Forms', 
'System.Drawing']


>
>>> Unfortunately, for most of what I would like, I believe it would 
>>> require WingIDE to support the use of IronPython. Is this accurate? 
>>
>> What do you mean by 'for most of what I would like'? Anything in 
>> addition to the two points above?
>
> No, I am not a WingIDE power-user yet. I am wanting to learn. I've 
> spent most of my time with Squeak Smalltalk so I do love the power of 
> a good IDE. But a couple of apps I am writing directly use .NET and 
> also COM DLLs. IronPython seemed like the best option for writing 
> those apps. One I have got permission to use ASP.NET MVC and 
> IronPython. Yay! no VB. :)
>
> Primarily at this point what I am missing and not seeing is the 
> autocompletion for the imported "mylibrary" and "clr" above. I 
> currently have neither.
>
> I will honestly admit I could easily be doing something wrong. Or I 
> did not change a preference or add your PI files or something. I would 
> be happy for that to be the case.

The only thing you haven't done is generate the PI files for the 
assemblies you want to use. Hopefully that will get you the autocomplete 
you are after.

All the best,


Michael Foord

>
>>> And if WingIDE did support the use of IronPython would it make what 
>>> you are doing easier or possibly unnecessary?
>>
>> The PI file mechanism is how Wing provides autocomplete - I've just 
>> made it work for .NET types, so this *is* Wing supporting IronPython. 
>> You can use Wing scripting to integrate other tools into Wing - see 
>> the example script I provided for running the current file with 
>> IronPython.
>
> Ok, I understand. I need to see how to use your work here. I have only 
> just yesterday downloaded WingIDE to try. So this is all new to me.
>
>> You might also want to integrate the IronPython debugger that Harry 
>> Pierson has been working on:
>>
>> http://ironpython-urls.blogspot.com/2009/04/further-adventures-of-debugger.html 
>
>
> Thanks. I give that a look.
>
> Jimmie
>
> _________________________________________________
> Wing IDE users list
> http://wingware.com/lists/wingide


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog




More information about the wingide-users mailing list