[Idle-dev] Adapting IDLE for different file types

Tal Einat taleinat at gmail.com
Sun Mar 25 21:05:47 CEST 2007

On 3/25/07, Keith R. Fieldhouse <idle at rexmere.com> wrote:
> Hello,
> I work on a project that uses Python as the basis for a very domain
> specific development environment.
> For documentation and training purposes I'd like to use IDLE as the
> initial development tool.  In other words, my "getting started"
> documentation and class exercises for example, would be produced in
> terms of IDLE.
> Thus far, this works quite well, IDLE strikes the right balance between
> simplicity, accessibility and capability.

I'm glad to hear - it means IDLE meets its goals :)

One issue is that our development environment has a number of domain
> specific text files used in the process of developing applications.
> Naturally, IDLE is able to edit these files with no problem.  I would,
> however, now like to add syntax colorization and possibly indentation
> support for these text files.
> Has any one done this?  Any thoughts on the proper approach or other
> hints would be greatly appreciated.   If there is some reason that this
> would be a Bad Idea, let me know that as well...

AFAIK and as far as 10 minutes of Google-ing can tell, this hasn't been
done. But I don't see any reason why this would be a Bad Idea.

As for thoughts on the proper approach: This could be an IDLE "extension".
See idlelib/extend.txt for an introduction to extensions, and check out some
of the built-in extensions, like ParenMatch and CodeContext.

For some technical details, check out EditorWindow.py:

        self.per = per = self.Percolator(text)
        if self.ispythonsource(filename):
            self.color = color = self.ColorDelegator()
            self.color = None

What your extension should do is call per.insertfilter(custom_colorizer),
where custom_colorizer would be your colorizer object. Your colorizer class
should inherit Delegator - see Delegator.py. Also see the implementation of
ColorDelegator in ColorDelegator.py, for a starting point.

Feel free to bug me with questions, I'd be glad to help :)

- Tal Einat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/idle-dev/attachments/20070325/aa1bf548/attachment.htm 

More information about the IDLE-dev mailing list