Ttk's menubutton widget.
jnc To invoke a menu button (or almost any other widget that takes a -text and -underline option) by a keystroke you can:
event generate $widget <<Invoke>>
Such as:
bind <Alt-f> . {event generate .menuButton <<Invoke>>}
HaO 2010-11-16 Is there any possibility to center-align the menu button text and image ? This would make the following example nicer (on Windows Vista classic theme):
("Laden" has nothing to do with the person, it is German for "Load (Module in this case)")
Labels and Images are left-aligned.
Code fragment (not that of the screenshot):
% pack [ttk::menubutton .t1 -text abcabcabc] -fill x % pack [ttk::menubutton .t2 -text a] -fill x
Style investigation:
% ttk::style layout TMenubutton Menubutton.border -sticky nswe -children {Menubutton.focus -sticky nswe -children {Menubutton.indicator -side right -sticky {} Menubutton.padding -expand 1 -sticky we -children {Menubutton.label - side left -sticky {}}}}
I think, the issue is the last part. "-side left -sticky {}" which should be changed to "-sticky news" Is this possible in an easy manner ?
--- Even harder, I want to have it with Toolbutton style:
% pack [ttk::menubutton .t1 -text abcabcabc -style Toolbutton] -fill x % pack [ttk::menubutton .t2 -text a -style Toolbutton] -fill x
How to align the labels "centered ?"
--- Style investigation:
% ttk::style layout Toolbutton Toolbutton.border -sticky nswe -children {Toolbutton.padding -sticky nswe -children {Toolbutton.label -sticky nswe}}
Here, the label has -sticky "nswe". So try some label-options:
% ttk::style configure Toolbutton.label -justify center -anchor center % pack [ttk::menubutton .t3 -text a -style Toolbutton] -fill x
But stil left-aligned...
But
% ttk::style theme use clam
and the Toolbutton styled menubuttons are center-aligned.
Why is a normal Button centered and a MenuButton left-aligned ?
If you have an answer feel free to remove all this and replace it by more helpful stuff. I have posted this on c.l.t. with no answer and solved it by putting the label to the right of the icon so it looks pretty when left-aligned.
EG: Remove the "-side left" and add "-sticky ns".
For plain ttk::menubuttons:
% ttk::style layout TMenubutton { Menubutton.border -sticky nswe -children { Menubutton.focus -sticky nswe -children { Menubutton.indicator -side right -sticky {} Menubutton.padding -expand 1 -sticky we -children { Menubutton.label -sticky ns } } } }
and for the Toolbutton styled ones:
% ttk::style layout Toolbutton { Toolbutton.border -sticky nswe -children { Toolbutton.padding -sticky nswe -children { Toolbutton.label -sticky ns } } }