Updated 2012-01-21 06:54:16 by RLE

Tk's menubutton documentation: http://purl.org/tcl/home/man/tcl8.4/TkCmd/menubutton.htm Ttk's menubutton documentation: http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_menubutton.htm

[Anyone want to contribute some examples of how to use this widget, along with tips and tricks, etc.? ]

        frame .menubar -borderwidth 0 -takefocus 0
        pack .menubar -side top -fill x
        menubutton .menubar.file -text File \
            -underline 0 -menu .menubar.file.m
        menubutton .menubar.edit -text Edit \
            -underline 0 -menu .menubar.edit.m
        menu .menubar.file.m -tearoff 0
        menu .menubar.edit.m -tearoff 0
        pack .menubar.file .menubar.edit -side left
        .menubar.file.m add command -label "Exit" \
            -underline 1 -command exit
        .menubar.edit.m add command -label "Cut" \
            -underline 2 \
            -command {event generate [focus] <<Cut>>}
        .menubar.edit.m add command -label "Copy" \
            -underline 0 \
            -command {event generate [focus] <<Copy>>}
        .menubar.edit.m add command -label "Paste" \
            -command {event generate [focus] <<Paste>>}
        text .t -wrap word
        pack .t -side top -fill both -expand y

What do menubuttons offer that menubars don't? [Chengye Mao] observes that a "menubutton works in an embedded window and a menubar does not." Moreover, some situations (including use of icons rather than labels?) preclude use of native menubars.

One disadvantage to using menubuttons rather than a native menubar is that on windows you don't get proper behavior when dragging from one menubutton to another. This is because the "unpost" menu command doesn't work on windows.

One advantage to using menubuttons rather than a native menubar is that you can have other widgets on the menubar (e.g. search box, status indicator, etc). Most UI design guidelines frown on such activities, however.