Tk/Tkinter apparently considers the position 1.13 to be after the last
word in the text. You get the same problem if you set the insertion
point just after the word 'two' for example: text.index('insert')
returns 1.7 and text.index('insert wordstart') returns 1.7 too...


Exactly.

My solution would simply be to go back one character before asking the
word start: text.index('insert - 1 chars wordstart') Don't know if
that'll do what you want if there are spaces at the end of the text. And
BTW, if you actually want the *last* word in the text, you may want to
use text.index('end - 2 chars wordstart'). Here, you have to use '- 2
chars' because end points to the first non-existent index (2.0 in your
case...).

HTH

Good idea, it seems to work fine now.
See you.

Kib².
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to