Daren Thomas Daren Thomas - 1 year ago 97
Bash Question

How to embed a graphical interactive IronPython shell in an application?

I've tried the obvious path in my pet open source project RevitPythonShell (a plugin for the building modeling software Autodesk Revit Architecture 2010):

with the IronPython engine set up to use .NET streams for
. These I then redirect to a
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
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
module), but for the life of me I can't figure it out. IronPython source code has no comments whatsoever.

UPDATE: After trying out some stuff, I eventually settled on the superb IronLab code. It includes an example shell with syntax highlighting and all. The code was nice and easy to integrate. Check the RevitPythonShell code on hints on how to embed it.

Answer Source

I was looking for a similar thing and I discovered that the IronLab project contains a nice IronPython console. The source code can be found here https://github.com/rwg0/ironlab/tree/master/IronPythonConsole.

[edit on 25/10/2016] fixed broken url

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download