From: jjplaw on
Simple Questions (newbie here):

[1] How do you change the font and font size in the themed button
widget (ttk::button)?

ttk::button .x.buttonTEST -text "TEST" -font??(option not valid with
ttk::button)

[2] Is there any method to change the height size of the ttk::button?

[3] Is it possible to have the text in two rows inside the
ttk::button?

please advise.
From: Pat Thoyts on
jjplaw <papunizer(a)gmail.com> writes:

>Simple Questions (newbie here):
>
>[1] How do you change the font and font size in the themed button
>widget (ttk::button)?
>
>ttk::button .x.buttonTEST -text "TEST" -font??(option not valid with
>ttk::button)
>
>[2] Is there any method to change the height size of the ttk::button?
>
>[3] Is it possible to have the text in two rows inside the
>ttk::button?
>
>please advise.

Create a style and use it with the widget.

font create MyFont -family "Courier New" -size 12
ttk::style configure My.TButton {*}[ttk::style configure TButton] \
-font MyFont
pack [ttk::button .b -text Styled -style My.TButton]

--
Pat Thoyts http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD
From: tom.rmadilo on
On Mar 17, 8:53 am, jjplaw <papuni...(a)gmail.com> wrote:
> Simple Questions (newbie here):
>
> [1] How do you change the font and font size in the themed button
> widget (ttk::button)?
>
> ttk::button .x.buttonTEST -text "TEST" -font??(option not valid with
> ttk::button)
>
> [2] Is there any method to change the height size of the ttk::button?
>
> [3] Is it possible to have the text in two rows inside the
> ttk::button?

Can I give you the newbie perspective? Pat Thoyts is of course right,
but what are the important parts?

Creating a new style.

New styles are children of current styles. But the syntax is somewhat
confusing, actually backwards of the syntax for child widgets.

My.TButton is a child style of TButton. It inherits all the properties
of TButton, and the configure options modify the inherited
properties.

My guess is that you should never try to alter the TButton style, or
any style, just create a derived style so you can easily reuse it and/
or change a widget style very easily.

Here's an example which creates several derived ttk styles:

http://junom.com/gitweb/gitweb.perl?p=sd.git;a=blob;f=visual-sudoku.tcl

The last few lines demonstrate the inheritance features:


74 ttk::style configure CButton.TButton -font {-size 10} -padding 0 -
background \#99CCFF -borderwidth -1 -width 2
75 ttk::style configure CurButton.TButton -font {-size 30} -padding 0 -
background \#6699CC -borderwidth 2 -width 2
76
77 ttk::style configure CFrame.TFrame -background \#336699
78 ttk::style configure BoxFrame.TFrame -background \#6699CC
79
80 ttk::style configure Yellow.CButton.TButton -background yellow

So TButton is used as the basis of CButton and CurButton. And CButton
is use as the basis of Yellow, which just changes the background color
of a widget by changing the style.

TkDocs website was very helpful for me: http://www.tkdocs.com/tutorial/styles.html

I change the style (background color) based upon a button click (bind
TButton <ButtonRelease-2>):

proc ::vsud::colorButton { path } {

switch -exact -- [$path cget -style] {

CButton.TButton {
$path configure -style Yellow.CButton.TButton
}
Yellow.CButton.TButton {
$path configure -style CButton.TButton
}
}
}
From: jjplaw on
thanks Pat Thoyts and tom.rmadilo for your guidance :)
I've got it now... will explore the other widget options
thanks again for your help

From: MSEdit on
On Mar 18, 4:58 am, jjplaw <papuni...(a)gmail.com> wrote:
> thanks Pat Thoyts and tom.rmadilo for your guidance :)
> I've got it now... will explore the other widget options
> thanks again for your help

When I had problems with this I had a look here http://www.tkdocs.com/index..html
especially
http://www.tkdocs.com/tutorial/styles.html which covers very clearly
what you need.

Martyn