|
Buttonbox
The Buttonbox performs geometry management for Pushbutton instances. Public commands exist which enable the user to add new Pushbuttons, define the default, and control their display. Options enable the user to establish the orientation. This class is used to manage the buttons for all dialogs in the [incr Widgets] mega-widget set.
For further information, see the Buttonbox
manpage
Components: hull
|
wm title . "Buttonbox Example"
##
## Supporting procs to show/hide buttons
##
proc more {} {
global current last
##
## Make sure that the current
## button is not the last one
##
if {$current < $last} {
.bb show button[expr {$current+1}]
incr current
}
if {$current == $last} {
.bb default less
}
return
}; # end proc more
proc less {} {
global current
##
## Make sure that the current is
## not zero
##
if {$current != 0} {
.bb hide button$current
incr current -1
} else {
.bb default more
}
return
}; # end proc less
##
## Supporting global variables
##
set current 0
set last 5
##=========================================================
## Create the buttonbox iwidget
##=========================================================
##
iwidgets::buttonbox .bb \
-padx 10 \
-pady 10
##
## Add some buttons to the box
##
foreach b {more less} {
.bb add $b \
-text [string totitle $b] \
-command "$b"
}
for {set b 1} {$b <= 5} {incr b} {
.bb add button$b \
-text [string totitle button$b]
.bb hide button$b
}
.bb default more
pack .bb \
-expand yes \
-fill both
|
Download this sample code |
|