Artifact Content

Artifact 06450760f64478c119ba4387f49f05c9e5b1ae13:

mactoolbar - Native Mac toolbar in Tk windows


package require mactoolbar

mactoolbar::createbutton identifier label tooltip imagepath cmd 

mactoolbar::create window


This package creates a Mac-native toolbar (based on the Cocoa NSToolbar) for use in Tk windows. 

The mactoolbar::createbutton command creates a command button that will be displayed in the toolbar, and takes five arguments: a string identifier for the toolbutton, a label for the toolbutton, a string for the toolbutton's tooltip, a path to an image that will be displayed in the button, and the Tcl command to execute. 

The mactoolbar::create command actually creates the toolbar, and takes a single argument, the window that will display the toolbar. 


The mactoolbar package offers a basic implementation of the NSToolbar library; it displays toolbar buttons, with labels and images, and does not display other Mac-native widgets such as the Cocoa searchfield. It does not allow customization, nor can it display Tk widgets. 

Also, it is important to set the "unifiedTitleAndToolbar" window flag, immediately after creating the toolbar, using the tk::unsupported::MacWindowStyle command; otherwise the internal geometry of Tk's widgets will be distorted. The window flag can be set like so:

tk::unsupported::MacWindowStyle style .f document {unifiedTitleAndToolbar standardDocument}


sheet, Mac, Cocoa