• Grid Widgets same width and -sticky w

    From Alexandru@21:1/5 to All on Mon Aug 14 02:42:53 2023
    On https://www.magicsplat.com/tcl-docs/docindex.html there is an example how all buttons in a grid row can have same uniform width.

    I would like that all button in the same column have same uniform width.

    I could do that with -sticky ew but then the content of each button is centered.

    Instead the content should be left aligned (-sticky e).

    Is there a trick how to do this?

    Thanks
    Alexandru

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Alexandru on Mon Aug 14 03:37:09 2023
    Alexandru schrieb am Montag, 14. August 2023 um 11:42:57 UTC+2:
    On https://www.magicsplat.com/tcl-docs/docindex.html there is an example how all buttons in a grid row can have same uniform width.

    I would like that all button in the same column have same uniform width.

    I could do that with -sticky ew but then the content of each button is centered.

    Instead the content should be left aligned (-sticky e).

    Is there a trick how to do this?

    Thanks
    Alexandru

    Correction:
    Instead the content should be left aligned (-sticky w).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Alexandru on Mon Aug 14 11:27:12 2023
    Alexandru <[email protected]> wrote:
    Alexandru schrieb am Montag, 14. August 2023 um 11:42:57 UTC+2:
    On https://www.magicsplat.com/tcl-docs/docindex.html there is an example how all buttons in a grid row can have same uniform width.
    I would like that all button in the same column have same uniform width.
    I could do that with -sticky ew but then the content of each button is centered.
    Instead the content should be left aligned (-sticky e).
    Is there a trick how to do this?
    Correction:
    Instead the content should be left aligned (-sticky w).

    Maybe you're looking for button's " -anchor w " ?
    (for grid, you still need -sticky nsew or ew)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Andreas Leitgeb on Mon Aug 14 13:04:09 2023
    Andreas Leitgeb schrieb am Montag, 14. August 2023 um 13:27:17 UTC+2:
    Alexandru <[email protected]> wrote:
    Alexandru schrieb am Montag, 14. August 2023 um 11:42:57 UTC+2:
    On https://www.magicsplat.com/tcl-docs/docindex.html there is an example how all buttons in a grid row can have same uniform width.
    I would like that all button in the same column have same uniform width. >> I could do that with -sticky ew but then the content of each button is centered.
    Instead the content should be left aligned (-sticky e).
    Is there a trick how to do this?
    Correction:
    Instead the content should be left aligned (-sticky w).
    Maybe you're looking for button's " -anchor w " ?
    (for grid, you still need -sticky nsew or ew)

    Yes! That's it. Here is a demo below.
    All 3 buttons have same lenght and the text is left aligned.

    ttk::button .b -style Toolbutton -text "Foo"
    ttk::button .e -style Toolbutton -text "Foo Foo"
    ttk::button .l -style Toolbutton -text "Foo Foo Foo"

    grid .b -sticky ew
    grid .e -sticky ew
    grid .l -sticky ew

    grid anchor .b w
    grid anchor .e w
    grid anchor .l w

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Tue Aug 15 10:53:04 2023
    * Alexandru <[email protected]>
    | Andreas Leitgeb schrieb am Montag, 14. August 2023 um 13:27:17 UTC+2:
    | > Alexandru <[email protected]> wrote:
    | > > Instead the content should be left aligned (-sticky w).
    | > Maybe you're looking for button's " -anchor w " ?
    | > (for grid, you still need -sticky nsew or ew)

    | Yes! That's it. Here is a demo below.
    | All 3 buttons have same lenght and the text is left aligned.

    | ttk::button .b -style Toolbutton -text "Foo"
    | ttk::button .e -style Toolbutton -text "Foo Foo"
    | ttk::button .l -style Toolbutton -text "Foo Foo Foo"

    | grid .b -sticky ew
    | grid .e -sticky ew
    | grid .l -sticky ew

    | grid anchor .b w
    | grid anchor .e w
    | grid anchor .l w

    I *think* that 'grid anchor' does something different than Andreas
    suggested.

    Andreas suggested to use the -anchor option of the ttk TButton style (he
    posted for 'button', but since you're using a 'ttk::button', you need to
    use the option with the same name of the ttk::style):

    # only specific buttons should get anchor w, so create a separate style for it:
    ttk::style configure W.TButton -anchor w

    # use that style with the specific buttons
    ttk::button .b -style Toolbutton -text "Foo" -style W.TButton
    ttk::button .e -style Toolbutton -text "Foo Foo" -style W.TButton
    ttk::button .l -style Toolbutton -text "Foo Foo Foo" -style W.TButton

    grid .b -sticky ew
    grid .e -sticky ew
    grid .l -sticky ew

    Compare the L&F of that to your code: on my system (Linux, tk8.6) with
    your code the relief of the buttons is missing.

    HTH
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Tue Aug 15 10:56:15 2023
    * Ralf Fassel <[email protected]>
    | ttk::button .b -style Toolbutton -text "Foo" -style W.TButton

    Ah, just spotted that you're using a separate Toolbutton style anyway,
    so just do

    ttk::style configure Toolbutton -anchor w

    and you should be done with your code.

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Ralf Fassel on Tue Aug 15 23:23:59 2023
    Ralf Fassel schrieb am Dienstag, 15. August 2023 um 10:56:20 UTC+2:
    * Ralf Fassel <[email protected]>
    | ttk::button .b -style Toolbutton -text "Foo" -style W.TButton
    Ah, just spotted that you're using a separate Toolbutton style anyway,
    so just do

    ttk::style configure Toolbutton -anchor w

    and you should be done with your code.

    R'
    Indeed, my code did work but only as it is. Ported in to the application, the result was nil.
    With
    ttk::style configure W.TButton -anchor w
    I get the wanted result.

    Many thanks for the help.

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