IDLE in any other GUI.
tim_one at email.msn.com
Thu Feb 17 05:10:27 CET 2000
[posted & mailed]
[Just van Rossum]
> Later, when Guido write Idle, I complained to him that his code
> was tightly bound to Tk, which I consider a platform also... (Of
> course he denied this...) It was not easy for me to take
> advantage of Idle's code in my own IDE. In the meantime, the
> situations has apparently become better, I believe PythonWin
> uses some parts of Idle.
Yes, and substantial rearranging & rewriting of the code (since the 1.5.2
release) was done to ease that.
> Some parts of an IDE are hard to factor out: eg. Idle's syntax
> coloring is neccesarily bound to Tk for performance reasons. I
> haven't studied the latest Idle sources, so I have no idea what
> how the amounts of "generic" code and Tk-dependent code relate,
> but it would be interesting to know.
> Anyone familiar enough with Idle guts to give a brief summary of
> what's there? Idle could be a killer app, but I think it has to
> separate itself from Tk as much as practical to actually
> become one.
The "deep" parts shared by IDLE and PythonWin are pointed to in IDLE's
EditorWindow.py, following the comment:
# Tk implementations of "virtual text methods" -- each platform
# reusing IDLE's support code needs to define these for its GUI's
# flavor of widget.
PythonWin uses an unrelated text widget, and so implements the methods
following this comment differently. All of the stuff for parsing Python
code, suggesting indentation (which is now as smart as the Emacs pymode --
which means "very smart"), and doing various reformatting are written in
terms of these "virtual text methods". So while it remains woefully
underdocumented, in practice it will prove easier than you fear <wink>.
There's one huge compromise: IDLE uses Tk-style text indices (line.column
strings, w/ various optional modifiers) throughout. Mark Hammond wrote a
layer around PythonWin's text widget (currently Scintilla, IIRC) to
translate its view of text indices to & from Tk's. This layer also contains
implementations for some Tk text commands, since they have to be spelled
*somehow* and Tk's spellings seem as good as anything else (e.g., text.get()
and text.delete() -- basic operations any text widget has to support).
if-tk-isn't-a-platform-python-isn't-a-language<wink>-ly y'rs - tim
More information about the Python-list