The flatbutton widget
Commands
::tclmacbag::flatbutton 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.
There is no size or colour recommendation for this widget.
- -command Command
The command to be executed when the button is clicked.
- -state State
Available values: normal or disabled.
- -force yes
Force the widget to use Mac style, even if the OS platform isn't a Mac.
::tclmacbag::flatbutton_Set pathName ?Options?
Available options:
- -image imageName
- -altimage imageName
- -command Command
- -state State
Example
set home [file dirname [info script]]
set picture1 [image create photo -file [file join $home image1.gif]]
set picture2 [image create photo -file [file join $home image2.gif]]
grid [ttk::frame .f]
grid [::tclmacbag::flatbutton .f.b1 -image $picture1 \
-command { puts "Box 1" }] -row 1 -column 1
grid [::tclmacbag::flatbutton .f.b2 -image $picture2 \
-command { puts "Box 2" }] -row 1 -column 2
grid [::tclmacbag::flatbutton .f.b3 -image $picture1 \
-command { puts "Box 3" } -force yes] -row 1 -column 3
grid [::tclmacbag::flatbutton .f.b4 -image $picture2 \
-command { puts "Box 4" } -state disabled -force yes] -row 1 -column 4
::tclmacbag::flatbutton_Set .f.b2 -state disabled
Further information
Only images are supported with this button.
However, an effective solution for those needing composite buttons is to use the grid geometry system and position a Tile/Ttk label directly underneath the
button.
You might like to use Tcllib's tooltip package to provide your users with additional textual hints if your button images might be misunderstood.
Do not attempt to change settings in this widget by using $w configure.
As is standard, ::tclmacbag::flatbutton returns with value of pathName, for ease of use with geometry managers like grid and
pack.