IDLE/Tk Text widget question

Tim Peters tim_one at email.msn.com
Sun May 2 12:10:04 EDT 1999


[Robert]
> ... In any [IDLE] EditorWindow, a manually inserted tab defaults to
> 8 spaces even though autoindent defaults to (I think) 4, which I much
> more prefer.

In the released 1.5.2 IDLE, hitting TAB inserts a literal tab character (not
spaces), and Tk creates the illusion of indent-to-multiple-of-8 columns.

In the current development IDLE (available (only) from the public CVS
repository on python.org), hitting TAB continues to do that in the Shell
window, but inserts literal spaces (up to the next higher multiple-of-4
columns) in file windows.  That's what you're asking for, so it's already
been done <wink>.

> I've looked at the text widget doc and it appears that to manually set
> tab stops, you need to use 'screen units' of cm, in, points, etc. but
> not characters.

The current IDLE is doing this itself, not trying to trick the Tk Text
widget into doing it; left to its own devices, the Text widget never inserts
spaces in response to a tab character.  If you want to fake this yourself
while retaining literal tab characters, I suppose you'll have to muck around
trying to define and compute the "average width" of a character in the font
you're using (not trivial for a proportional font!).

a-space-is-worth-a-page-of-calculation-ly y'rs  - tim








More information about the Python-list mailing list