Mailing List Archive

IDLE/Tk Text widget question
Hi,
I've finally decided to use IDLE and also to learn Tk (I normally use
MFC and VC++ for GUI stuff, python for text based stuff).

I think IDLE is a great IDE and all, but there is one thing that is
annoying, that is actually I suspect a problem with Tk. In any EditorWindow,
a manually inserted tab defaults to 8 spaces even though autoindent defaults
to
(I think) 4, which I much more prefer. 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. Am I missing something? How could
the
default spacing be 8 characters/spaces and yet there is no way to specify
units of characters?

Robert
IDLE/Tk Text widget question [ In reply to ]
[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