The Fx_Menubar widget occurs exactly once per application. When
you specify the [menubar]
command, QddbScript
creates a new Tcl command called ``menubar'' and the menubar
is packed into a Tk frame called ``.menubar''. You can insert
Tk code directly after the [menubar]
command to create
a new menubutton and associated Tk menu:
# ... [menubar] [code value={ menubutton .menubar.mymenu -text Mymenu \ -underline 1 -menu .menubar.mymenu.menu menubar configure -auxbuttons .menubar.mymenu menu .menubar.mymenu.menu -tearoff 0 .menubar.mymenu.menu add command -label "Hello" \ -underline 0 -command { tk_dialog .dialog "Hello World" "Hello World" \ info 0 Ok } }] # ...
Of course, the code is much cleaner if you put it into a
procedure that can be called from your application's library.
Using the code above, our Invoices database now has a new
menubutton called ``Mymenu'' with a <Alt-y>
accelerator:
Mymenu consists of one menu item called Hello. You can add as many menubuttons and menuitems as you like. Note that your menubar customizing procedure should contain a call similar to this:
menubar configure -auxbuttons { .menubar.menu1 .menubar.menu2 .menubar.menu3 }
The argument to -auxbuttons must contain all auxilliary menubuttons or they will not be packed properly in the menubar.