|
From: Joe E. <jen...@fl...> - 2004-10-06 21:33:50
|
Joi Osoy wrote:
>
> I am building a vertical button box and would like my
> buttons to have their text left-justified.
Do the buttons have images too, or just text?
> It works fine with regular Tk buttons, but not when
> using tile toolbuttons. I have tried -justify left but
> it does not work (still centered)
>
> I have also tried defining a new layout but no luck
> either
There are three things that affect where the label appears:
(1) The -side and -sticky options in the layout specification
determine where the label element is placed within the parcel.
So you could use:
style layout Buttonbox.Button {
Button.border -children {
Button.focus -children {
Button.padding -children {
Button.label -side left -sticky w <== here
}
}
}
}
(-sticky nwse is the default, and if -side is omitted it means
"use the entire parcel").
Or, if you want the focus ring to wrap around the label
instead of being inside the border:
style layout Buttonbox.Button {
Button.border -children {
Button.padding -children {
Button.focus -side left -sticky w -children {
Button.label
}
}
}
}
(2) The label element has an "-anchor" option that determines
where to place the label inside the parcel. For [ttk::label]
widgets, you can set -anchor on the widget itself. On other
widgets like checkbuttons, -anchor is a compatibility option,
so it can only be set on the style:
style default ButtonBox.Button -anchor w
(The way things are organized, there is a choice between getting the
focus ring in the right place or having a working -anchor option.
The first is more important, which is why -anchor isn't a "real"
widget option.)
(3) If there are multiple lines, the text element "-justify" option
determines how they line up. As with "-anchor", only label widgets
have this option, for checkbuttons &c it can only be set in the style.
Other notes: the label element is actually a combination of the
"text" and "image" elements. "-wraplength" and "-justify" are
text element options, "-anchor" and "-compound" are handled by
the label element.
--Joe English
jen...@fl...
|