The tabs
option for Text
widgets gives you a number of ways to set tab stops
within the widget.
The default is to place tabs every eight characters.
To set specific tab stops, set this option to a
sequence of one or more distances. For example,
setting tabs=('3c', '5c', '12c')
would
put tab stops 3, 5, and 12cm from the left side.
Past the last tab you set, tabs have the same width
as the distance between the last two existing tab
stops. So, continuing our example, because 12c-5c
is 7 cm, if the user keeps pressing
the Tab key, the cursor would be
positioned at 19cm, 26cm, 33cm, and so on.
Normally, text after a tab character is aligned with
its left edge on the tab stop, but you can include
any of the keywords tk.LEFT
, tk.RIGHT
, tk.CENTER
, or tk.NUMERIC
in the list after a distance, and
that will change the positioning of the text after
each tab.
A tk.LEFT
tab stop has the default
behavior.
A tk.RIGHT
tab stop will position the
text so its right edge is on the stop.
A tk.CENTER
tab will center the
following text on the tab stop.
A tk.NUMERIC
tab stop will place
following text to the left of the stop up until the
first period ('.'
) in the
text—after that, the period will be centered on
the stop, and the rest of the text will positioned to
its right.
For example, setting tabs=('0.5i', '0.8i',
tk.RIGHT, '1.2i', tk.CENTER, '2i', tk.NUMERIC)
would set four tab stops: a left-aligned tab stop half an
inch from the left side, a right-aligned tab stop
0.8″ from the left side, a center-aligned tab stop
1.2″ from the left, and a numeric-aligned tab stop
2″ from the left.