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

Questions about geometry managers and about marks in text widgets

0 views
Skip to first unread message

kenneth.m...@gmail.com

unread,
Aug 23, 2005, 4:03:41 AM8/23/05
to
I'm finally getting back to doing some Tkinter work after a long
hiatus. Two things I'd like to be able to do in Tkinter, but don't seem
possible in Tk (and hence not in Tkinter :-)) are

1) Move a frame or other widget from one location to another, under
a different parent. So far as I can see, this is not possible, it would
be necessary to destroy the widget and rebuild it.

2) Text marks gave me a lot of trouble when I used them before, and
I'm wondering if any functionality has been added that would fix this.
(In some ways, I regard this as a semantic bug in Tk, because it makes
marks act very counterintuitively in some circumstances. Here's the
problem:

Let [1, [2, etc. reprsent marks with gravity set so that text inserted
in them get inserted to their right. Similarly, let ]1, ]2 etc be marks
such that text inserted at them is inserted to their left. In some
sense this is a natural mapping, they are considered as the beginning
and end of a range of text. Now let letters represent the text. Here's
a text sequence:

[1 A [2 B 2] C ]1

We now remove all the text to produce an empty string with the
following marks, and get

[1[22]1]

Now I insert A at 1] Because of it's gravity, the text is inserted to
that mark's left; but it is also inserted to the left of ]2! So I get
[1[2A2]1]. In fact, there is (or at least was) no easy way to insert
text between ]2 and ]1.

It gets even worse if we start with something like this:

[1 A ]1 B [2 C ]2

Now delete all the text:
[1]1[2]2
Now insert at [2: the result is
[1[2A1]2]
The problem is that marks which are collapsed to the same index
maintain no sense of their relative ordering. I tried fighting this for
a long time, and eventually gave up, as the attempted solutions became
too complex. Have there been any changes since the earlier versions of
8.4? Has anyone written code to work around this problem?

If one tries to do this with tags, the problem is that the tags
disappear if they become empty, or merge if they come into contact.

Thanks for the help,
Ken McDonald

Jeff Hobbs

unread,
Aug 24, 2005, 12:48:49 AM8/24/05
to
kenneth.m...@gmail.com wrote:
> I'm finally getting back to doing some Tkinter work after a long
> hiatus. Two things I'd like to be able to do in Tkinter, but don't seem
> possible in Tk (and hence not in Tkinter :-)) are
>
> 1) Move a frame or other widget from one location to another, under
> a different parent. So far as I can see, this is not possible, it would
> be necessary to destroy the widget and rebuild it.

Currently rebuild is the only option. Tk provides a reasonble
level of introspection so a general function code do it.
However, 8.5 is targetted to have reparenting built in (TIP
125), it just isn't trivial across platforms.

> 2) Text marks gave me a lot of trouble when I used them before, and
> I'm wondering if any functionality has been added that would fix this.
> (In some ways, I regard this as a semantic bug in Tk, because it makes
> marks act very counterintuitively in some circumstances. Here's the
> problem:

...


> The problem is that marks which are collapsed to the same index
> maintain no sense of their relative ordering. I tried fighting this for
> a long time, and eventually gave up, as the attempted solutions became
> too complex. Have there been any changes since the earlier versions of
> 8.4? Has anyone written code to work around this problem?

That was somewhat confusing in example, but you may well be
right that relative ordering gets confused on a single point.
8.5 does have numerous text widget enhancements, including
peering, tabstop changes and some other things. You might
experiment to see if some of those changes addressed tags.
Vince Darley probably knows the most about text innards now.

--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos

0 new messages