views:

266

answers:

1

I've tried the obvious path in my pet open source project RevitPythonShell (a plugin for the building modeling software Autodesk Revit Architecture 2010): code.interact() with the IronPython engine set up to use .NET streams for STDIN and STDOUT. These I then redirect to a TextBox control. It kinda works, but really is only an ugly hack.

The main problem is getting all the shell stuff to work: Up-arrow and down-arrow for history, editing, copy & paste, EOF, syntax highlighting, tool tips etc. It takes a lot of work to get this right, and it is not really the problem I'm trying to solve (I'm trying to get an interactive shell hosted in Revit, not make the perfect shell GUI).

If this weren't a .NET project, I'd probably look into reusing PyCrust/PyWrap, but I'm not sure if that can be done from a WinForms project. Is there anything similar for .NET?

Has anyone ever implemented the IConsole interface and can show an example of what I'd need to do? It seems this would be the proper route to go (as opposed to using the code module), but for the life of me I can't figure it out. IronPython source code has no comments whatsoever.

+2  A: 

Ok, then I have two possible answers. One in the comment above....and another far simpler (no intellisense, no syntax highlighting):

http://www.codeproject.com/KB/edit/irontextbox2.aspx

It's by JoeSox, and it is for IronPython 2, not 2.6. However I was able to update it to work properly with 2.6 in about five minutes. If you are interested I can figure out a way to send you a diff file or slap the updated project somewhere (it was published under an MIT license).

Enjoy!

David

djlawler
sweet :) just what I was looking for! Will report back here when I get it running!
Daren Thomas