From: JHJL on
On Apr 20, 12:32 pm, JHJL <j...(a)hippospace.com> wrote:
> Hi all
>
> I really cannot fathom how to simply make a ttk::button's label center
> jusitfied. I have tried looking at ttk::style man page and determined
> that there is a Button.label element which does have a -justify
> option, how on earth do I set it?
>
> Any ideas greatfully received
>
> kind regards
> Julian H J Loaring

forgot to say that the button labels have two lines

eg .b configure -text "first line\nsecond line"

by default ttk left aligns the label which (to me) looks ugly
From: Georgios Petasis on
στις 20/4/2010 14:35, O/H JHJL έγραψε:
> On Apr 20, 12:32 pm, JHJL<j...(a)hippospace.com> wrote:
>> Hi all
>>
>> I really cannot fathom how to simply make a ttk::button's label center
>> jusitfied. I have tried looking at ttk::style man page and determined
>> that there is a Button.label element which does have a -justify
>> option, how on earth do I set it?
>>
>> Any ideas greatfully received
>>
>> kind regards
>> Julian H J Loaring
>
> forgot to say that the button labels have two lines
>
> eg .b configure -text "first line\nsecond line"
>
> by default ttk left aligns the label which (to me) looks ugly

I think that you need to create a new style:


ttk::style configure My.TButton -justify center
ttk::button .b -style My.TButton -text "first line\nsecond line"

I think one of the best tutorials about ttk is here:

http://www.tkdocs.com/tutorial/

Chapter 15.

George
From: JHJL on
On Apr 20, 1:42 pm, Georgios Petasis <peta...(a)iit.demokritos.gr>
wrote:
> στις 20/4/2010 14:35, O/H JHJL έγραψε:
>
>
>
>
>
> > On Apr 20, 12:32 pm, JHJL<j...(a)hippospace.com>  wrote:
> >> Hi all
>
> >> I really cannot fathom how to simply make a ttk::button's label center
> >> jusitfied. I have tried looking at ttk::style man page and determined
> >> that there is a Button.label element which does have a -justify
> >> option, how on earth do I set it?
>
> >> Any ideas greatfully received
>
> >> kind regards
> >> Julian H J Loaring
>
> > forgot to say that the button labels have two lines
>
> > eg .b configure -text "first line\nsecond line"
>
> > by default ttk left aligns the label which (to me) looks ugly
>
> I think that you need to create a new style:
>
> ttk::style configure My.TButton -justify center
> ttk::button .b -style My.TButton -text "first line\nsecond line"
>
> I think one of the best tutorials about ttk is here:
>
> http://www.tkdocs.com/tutorial/
>
> Chapter 15.
>
> George- Hide quoted text -
>
> - Show quoted text -

Many thanks for Georgios, that works.

Alas I am still mystified as to how setting -justify on the style gets
propogated down to configure the Button.label element! Even after
reading the tutorial :-)

kind regards
Julian
From: Georgios Petasis on
στις 20/4/2010 17:24, O/H JHJL έγραψε:
> On Apr 20, 1:42 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
> wrote:
>> στις 20/4/2010 14:35, O/H JHJL έγραψε:
>>
>>
>>
>>
>>
>>> On Apr 20, 12:32 pm, JHJL<j...(a)hippospace.com> wrote:
>>>> Hi all
>>
>>>> I really cannot fathom how to simply make a ttk::button's label center
>>>> jusitfied. I have tried looking at ttk::style man page and determined
>>>> that there is a Button.label element which does have a -justify
>>>> option, how on earth do I set it?
>>
>>>> Any ideas greatfully received
>>
>>>> kind regards
>>>> Julian H J Loaring
>>
>>> forgot to say that the button labels have two lines
>>
>>> eg .b configure -text "first line\nsecond line"
>>
>>> by default ttk left aligns the label which (to me) looks ugly
>>
>> I think that you need to create a new style:
>>
>> ttk::style configure My.TButton -justify center
>> ttk::button .b -style My.TButton -text "first line\nsecond line"
>>
>> I think one of the best tutorials about ttk is here:
>>
>> http://www.tkdocs.com/tutorial/
>>
>> Chapter 15.
>>
>> George- Hide quoted text -
>>
>> - Show quoted text -
>
> Many thanks for Georgios, that works.
>
> Alas I am still mystified as to how setting -justify on the style gets
> propogated down to configure the Button.label element! Even after
> reading the tutorial :-)
>
> kind regards
> Julian

When you change an option on a style, this option changes in all
elements that support this option, skipping elements that do not support
the option.

So, when you discovered that the label element has a -justify (or a
-anchor) option, the way to change it is through the style command.

So, if you change the TButton style, it will affect all buttons (since
the TButton is the default button style). A better way to do it, is
through creating a new style. Naming the new style "Anything".TButton,
means "inherit" everything from TButton, so My.TButton has all the
properties from TButton, but with different -justify option for all
elements that support it.

George
From: JHJL on
On Apr 20, 4:19 pm, Georgios Petasis <peta...(a)iit.demokritos.gr>
wrote:
> στις 20/4/2010 17:24, O/H JHJL έγραψε:
>
>
>
>
>
> > On Apr 20, 1:42 pm, Georgios Petasis<peta...(a)iit.demokritos.gr>
> > wrote:
> >> στις 20/4/2010 14:35, O/H JHJL έγραψε:
>
> >>> On Apr 20, 12:32 pm, JHJL<j...(a)hippospace.com>    wrote:
> >>>> Hi all
>
> >>>> I really cannot fathom how to simply make a ttk::button's label center
> >>>> jusitfied. I have tried looking at ttk::style man page and determined
> >>>> that there is a Button.label element which does have a -justify
> >>>> option, how on earth do I set it?
>
> >>>> Any ideas greatfully received
>
> >>>> kind regards
> >>>> Julian H J Loaring
>
> >>> forgot to say that the button labels have two lines
>
> >>> eg .b configure -text "first line\nsecond line"
>
> >>> by default ttk left aligns the label which (to me) looks ugly
>
> >> I think that you need to create a new style:
>
> >> ttk::style configure My.TButton -justify center
> >> ttk::button .b -style My.TButton -text "first line\nsecond line"
>
> >> I think one of the best tutorials about ttk is here:
>
> >>http://www.tkdocs.com/tutorial/
>
> >> Chapter 15.
>
> >> George- Hide quoted text -
>
> >> - Show quoted text -
>
> > Many thanks for Georgios, that works.
>
> > Alas I am still mystified as to how setting -justify on the style gets
> > propogated down to configure the Button.label element! Even after
> > reading the tutorial :-)
>
> > kind regards
> > Julian
>
> When you change an option on a style, this option changes in all
> elements that support this option, skipping elements that do not support
> the option.
>
> So, when you discovered that the label element has a -justify (or a
> -anchor) option, the way to change it is through the style command.
>
> So, if you change the TButton style, it will affect all buttons (since
> the TButton is the default button style). A better way to do it, is
> through creating a new style. Naming the new style "Anything".TButton,
> means "inherit" everything from TButton, so My.TButton has all the
> properties from TButton, but with different -justify option for all
> elements that support it.
>
> George

And then all became clear. Thank you so much for your time and
consideration Georgios.

kind regards
Julian