The viewbutton widget
In Brief
Supports a number of button styles:
Commands
::tclmacbag::viewbutton pathName ?Options?
Available options:
- -image imageName
The imageName should have been previously created by the Tk Photo package or equivalent.
If using the Tk Photo package itself for this purpose, it should be noted that the Tk 8.4 version doesn't handle
PNG format images well on the Mac platform. Try using GIF format or the TkPNG package.
- -background colourLabel
This optional option sets the colour of the area which appears visually outside the button but inside the button widget.
This colour can be any standard colour name or label, such as '#AABB00' or 'white'. If this option is not used, this colour
will default to the Tile theme's standard background colour (which, on Mac, maps to the pinstripe texture)..
- -command Command
The command to be executed when the button is clicked.
- -style pill|chrome|steel|simple|safari|capsule
The name of the button decoration style to be used.
For buttons arranged together, specifiy the location in the style. Eg: 'pill-left', 'capsule-middle', 'safari-right', and so on.
Style fashions change quite a bit in the Mac world. The 'safari' style is probably the most in vogue at the moment.
- -variable VarName
The name of a variable to trace.
- -onwhen Value
The value the variable should be for the widget to consider this particular viewbutton has been selected and pressed.
The variable should be the same for each of the viewbuttons in a set, with the value differing between each viewbutton.
- -force yes
Force the widget to use Mac style, even if the OS platform isn't a Mac.
Example
::tclmacbag::viewbutton .f.b1 -background #B2B2B2 -image $img \
-style steel-left -command {set ::a 1 ; puts Test} -force yes \
-variable ::a -onwhen 1
Further Information
Supports the
-force yes option to enable the Mac versions of the widget to be used on non-Mac platforms
(as seen in the above screenshot from an ancient copy of Windows 98).
Without -force yes used, widgets appear on non-Mac platforms as standard Tile/Ttk buttons.
Images with this widget should be 13 pixels high and (usually but not always) 13 pixels in width.
By strong convention, icon images should be dark coloured greyscale, with a transparent background. (This reflects the history of this button class in the Mac OS range before OS X.)
The exception to this rule is the 'mail' style (named for Apple's Mail.app) which uses colour icons.