• ttk::label

    From Manfred Stelzhammer@21:1/5 to All on Sun Dec 24 12:58:10 2023
    Hi

    ##

    wm geometry . 400x200
    pack [ttk::label .lab1 -justify center -text testtext] -fill x
    pack [label .lab2 -justify center -text testtext] -fill x

    ##

    The text from .lab1 is on the right site.
    The text from .lab2 is on the center.

    Why this different behavior.

    Do I something wrong.

    regards and merry xmas

    Manfred

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Manfred Stelzhammer@21:1/5 to All on Sun Dec 24 14:50:55 2023
    I know

    I think "-justify center" should show the text on both (ttk::label and
    label) in the center.
    But it doesn't. Why.

    Regeards Manfred



    Am 24.12.23 um 14:10 schrieb greg:
    Manfred Stelzhammer schrieb am Sonntag, 24. Dezember 2023 um 12:58:16 UTC+1:
    Hi

    ##

    wm geometry . 400x200
    pack [ttk::label .lab1 -justify center -text testtext] -fill x
    pack [label .lab2 -justify center -text testtext] -fill x

    ##

    The text from .lab1 is on the right site.
    The text from .lab2 is on the center.

    Why this different behavior.

    Do I something wrong.

    regards and merry xmas

    Manfred

    #label != ttk::label

    package require Tk
    ##
    #https://www.tcl.tk/man/tcl/TkCmd/label.html #https://www.tcl.tk/man/tcl/TkCmd/ttk_label.html
    wm geometry . 400x200
    pack [ttk::label .lab1 -justify center -text "testtext 1"] -fill x
    pack [ttk::label .lab2 -justify center -text "testtext 2"] -fill x

    pack [label .lab3 -justify center -text "testtext 3"] -fill x
    pack [label .lab4 -justify center -text "testtext 4"] -fill x

    ##

    Gregor

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to Manfred Stelzhammer on Sun Dec 24 15:34:38 2023
    On 24/12/2023 14:50, Manfred Stelzhammer wrote:
    I think "-justify center" should show the text on both (ttk::label and
    label) in the center.
    But it doesn't. Why.

    As the manual page says, the -justify option relates to multi-line
    strings: "If there are multiple lines of text, specifies how the lines
    are laid out relative to one another". Relative to one another, not to
    the label overall. Since your labels only have one line of text, the
    -justify option has no effect.

    To center the text on the labels you must use a different option:
    -anchor. This should do what you want:

    wm geometry . 400x200
    pack [ttk::label .lab1 -anchor center -text testtext] -fill x
    pack [label .lab2 -anchor center -text testtext] -fill x


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Manfred Stelzhammer@21:1/5 to All on Sun Dec 24 16:34:51 2023
    Am 24.12.23 um 15:34 schrieb Schelte:
    wm geometry . 400x200
    pack [ttk::label .lab1 -anchor center -text testtext] -fill x
    pack [label .lab2 -anchor center -text testtext] -fill x

    Thank's.
    That's what I'm looking for.

    Regards

    Manfred

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)