TclMacBag - Bag of Mac Widgets for Tcl/Tk
The toolbar widget

HomeF.A.QChangelogLicenseAbout

In Brief

When the end-user clicks the righthand toolbutton in the window decor, the managed frame is "forgotten" or "shown" depending on the toggle state.

This command sets the bindings required on Mac. It acts as a simple wrapper around grid for Windows and X11 users.

The toolbar widget will appear in TclMacBag from v0.08.

Commands

::tclmacbag::toolbar pathName ?Options?

The options used by this should be the arguments you would be using for grid.

This command sets up the bindings required for the user to toggle the display of the frame with their tool button.

::tclmacbag::toolbar_Toggle pathName

Toggles the current state of the toolbar frame.

You can use this to control the frame independently of the toolbar button.

::tclmacbag::toolbar_ToggleTo pathName ?Options?

Sets the toggle of the toolbar frame to a particular state.

Options:

This command is available from v0.09.

Example

::tclmacbag::toolbar [ttk::frame .f] -column 1 -row 1 -sticky nsew -columnspan 2

Setting the toolbar state manually

The toggle state is managed using the variable ::tclmacbag::toolbarhidden($tl), where $tl is the managed frame's toplevel.

To simply toggle the state (triggered for example by an entry in your menus), simply use:

# Where $w is the toolbar managed frame
::tclmacbag::toolbar_Toggle $w

To have the widget change to a particular state, use:

# Set toggle to: on
::tclmacbag::toolbar_ToggleTo $w -state on

Further Information

The pack method may be supported at a later date but is not currently. The place method is unlikely to be supported.

An application may only have one toolbar per toplevel.

From v0.14, the current state of the widget is located in: ::tclmacbag::toolbarisdisplayed($toplevel). This is particularly handy for providing control via a Tk menu checkbutton item.

© Peter Caffin, 2010-2017.