Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Removing dependency on "anchor" tag

5 views
Skip to first unread message

Weeble

unread,
Jan 29, 2009, 4:01:11 AM1/29/09
to
Hi,
I'm trying to fix some code in Python's IDLE editor that broke
with Tk 8.5. It depended on being able to find the "anchor" tag on a
text widget in order to keep the text selection working while
providing custom behaviour for the home key: the first press should
send the cursor to the first non-whitespace character on the line, and
subsequent presses should toggle between that position and the
absolute start of the line.

The problem is that it tries to read the "anchor" mark in order to
correctly update the selection, but in Tk 8.5 it has been renamed to
be unique to each text widget and is noted to be private. What is the
correct way to customise this behaviour? I can get it to work by
calling tk::TextKeySelect (and the resulting code is much simpler!)
but I'm not sure if this is really supposed to be a public method. Is
it just as likely to change in future versions? How many versions back
will it work? Is there a better way? I don't think reimplementing the
entire text selection system is a viable option.

Many thanks,
Weeble.

Weeble

unread,
Jan 29, 2009, 4:14:40 AM1/29/09
to
On Jan 29, 9:01 am, Weeble <clockworksa...@gmail.com> wrote:
> Hi,
>     I'm trying to fix some code in Python's IDLE editor that broke
> with Tk 8.5. It depended on being able to find the "anchor" tag...

Oops, obviously I mean anchor *mark*, not tag.

Koen Danckaert

unread,
Jan 29, 2009, 11:10:25 AM1/29/09
to
Weeble wrote:
> I'm trying to fix some code in Python's IDLE editor that broke
> with Tk 8.5. It depended on being able to find the "anchor" tag on a
> text widget in order to keep the text selection working while
> providing custom behaviour for the home key: the first press should
> send the cursor to the first non-whitespace character on the line, and
> subsequent presses should toggle between that position and the
> absolute start of the line.
>
> [...] I don't think reimplementing the

> entire text selection system is a viable option.

Well, maybe it is... but someone else already did it for you. Have a look at the ntext package in tklib, discussed on http://wiki.tcl.tk/17976

--Koen

0 new messages