[Idle-dev] IDLE Line numbering initial plan

Saimadhav Heblikar saimadhavheblikar at gmail.com
Sun Jun 15 16:50:55 CEST 2014


An open issue for this topic[1].

This email details how I want to add line numbering to IDLE. The mock is at

This will be only added to EditorWindow and OutputWindow.

The tk.Text class will be replaced by a Text class which inherits from
tk.Text as in the mock(line 50). Basically, a virtual event called
<<changed>> is going to be generated when the following actions take
insert, delete, replace, when 'insert' is changed, the window moves etc.
The Text object will intercept this call, trigger <<changed>>. It will
propagate the original call, as well.
The line number canvas will be at the left of the text area. It will
be redrawn, whenever the above events take place.

I was worried about memory usage due to constant redrawing, but the
memory never increased beyond 5.3 MiB. This is good, given a text
widget on its own takes 5.0 MiB.
Processor usage was same in both cases.

As far as details like background, color of text etc are concerned,
they will be added to config-highlight.def.

There will be a menu option to toggle the line numbering canvas
on-off. Would something like the "Code Context" option in "Options"
menu be good?

The open issue[1] says it should be enabled by default. That to me
seems like the right way to do it. But if we were to do it as an
extension, will the existing extension mechanism allow it?(Especially
the tk.Text overriding part). Could someone familiar with the
mechanism could fill me in on it?

Should the linenumbering related code go into a new class and the Text
widget be imported from there, or should it be added into EditorWindow
itself?(LineNumber canvas, the interception mechansim etc)

[1] http://bugs.python.org/issue17535

[2] https://bitbucket.org/sahutd/linenumbering-mockup/src/d311c81a6fbcfa10d125279d616fb90c9745aab6/line-numbering-mockup.py?at=default

Saimadhav Heblikar

More information about the IDLE-dev mailing list