[Tutor] remap tab key to 4 spaces in a Tkinter text box
john at fouhy.net
Fri Oct 31 02:31:33 CET 2008
2008/10/31 <dwbarne at earthlink.net>:
> Hi tutors.
> Is there a way to remap a tab key to enter a user-specified number of spaces in a Tkinter text widget instead of a genuine tab? An internet search has turned up zilch. The tab option in a text widget lets you enter the number of centimeters to space over, but this option is truly useless when you want real live spaces instead.
> I tried using 'bind' to call a method that inserts 4 spaces, for example, but this approach enters the number of spaces AND a tab as well (as expected, after thinking about it). Not good.
My Tkinter is a bit rusty, but the latter approach might be the one to
take. Just remember to return 'break' at the end of your callback.
This prevents the event from being passed on to the text widget.
More information about the Tutor