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

ttk::label vs label - multiline text

158 views
Skip to first unread message

Googie

unread,
Jul 18, 2012, 4:09:15 PM7/18/12
to
Hi,

I just noticed that if I use multiline text for a label and ttk::label, they behave differently in case parent frame/toplevel shrinks (in regards of a width).
The [label] shows as much text as is possible, but [ttk::label] hides lines other than first, which is weird to me.

Example to reproduce:

ttk::label .l1 -text "this is a test of a long line\nwith multiple lines" -justify left
label .l2 -text "this is a test of a long line\nwith multiple lines" -justify left
pack .l1 .l2

Now resize the toplevel so labels won't fit in width, but leave enough height. You will see that only [ttk::label] hides second line.

Does it happen to you too?

There is also second, minor difference - [label] sticks always center of the label and [ttk::label] sticks always left side of the label. In result when you resize the window, the [label] seems to be moving, while [ttk::label] stays at it's place.

Second difference is not so much disturbing. Well, at least not for my needs ;)

Regards,
Pawel

Jeff Godfrey

unread,
Jul 18, 2012, 5:15:13 PM7/18/12
to
On Wednesday, July 18, 2012 3:09:15 PM UTC-5, Googie wrote:
> Hi,
>
> I just noticed that if I use multiline text for a label and ttk::label, they behave differently in case parent frame/toplevel shrinks (in regards of a width).
> The [label] shows as much text as is possible, but [ttk::label] hides lines other than first, which is weird to me.
>
> Example to reproduce:
>
> ttk::label .l1 -text "this is a test of a long line\nwith multiple lines" -justify left
> label .l2 -text "this is a test of a long line\nwith multiple lines" -justify left
> pack .l1 .l2
>
> Now resize the toplevel so labels won't fit in width, but leave enough height. You will see that only [ttk::label] hides second line.
>
> Does it happen to you too?
>
> There is also second, minor difference - [label] sticks always center of the label and [ttk::label] sticks always left side of the label. In result when you resize the window, the [label] seems to be moving, while [ttk::label] stays at it's place.
>
> Second difference is not so much disturbing. Well, at least not for my needs ;)
>
> Regards,
> Pawel

Regarding the 2nd line of the ttk::label disappearing when crowded - I do see it here (Win7 8.4.9), but don't necessarily have an explanation.

Regarding the text location differences between the two labels... It looks like the ttk::label must default to "-anchor w" while the tk label must default to "-anchor c". Explicitly setting a common anchor value on both controls should make them react the same in this regard.

Jeff

Googie

unread,
Jul 18, 2012, 5:30:30 PM7/18/12
to
> Regarding the 2nd line of the ttk::label disappearing when crowded - I do see it here (Win7 8.4.9), but don't necessarily have an explanation.
>
> Regarding the text location differences between the two labels... It looks like the ttk::label must default to "-anchor w" while the tk label must default to "-anchor c". Explicitly setting a common anchor value on both controls should make them react the same in this regard.

Thanks for the answer. The -anchor did the job with second difference. I'm also glad that the first issue happens also elsewhere and not just my pc doing some weird staff.

Cheers,
Googie

Donal K. Fellows

unread,
Jul 19, 2012, 1:12:27 AM7/19/12
to
On 18/07/2012 22:09, Googie wrote:
> Now resize the toplevel so labels won't fit in width, but leave
> enough height. You will see that only [ttk::label] hides second line.

There was a bug (#3294450) in the Ttk element used to do the text
rendering: it would stop drawing text after hitting the edge, in a
misguided attempt to do clipping in character-space. I fixed the bug a
few weeks ago. This will be available in the next release (probably this
week for 8.5.12, 8.6b3 will take a little longer; we're working on RCs
for both).

Donal.
0 new messages