button types:
button/checkbutton/radiobutton
checkbutton放在一起可多选,radionbutton放在一起单选
每个checkbutton提供是否选中的1或0,而多个radionbutton仅提供一个变量,选中后体现为变量的值。
OPTIONS
-command
$b = $mw->Button(-text => 'Blue', -command => [\&change_color, 'blue'])->pack;
[]代表后面还有个参数?我猜的
-variable
$mw->Checkbutton(-text => 'Print Header', -variable => \$print_header);
注意传递的是一个引用
-value
$mw->Radiobutton(-text => '$' . $_, -variable => \$group1, -value => $_)->pack(-side => 'left');
对于radionbutton,还得传递一个value值给variable
-textvariable
$mw->Button(-textvariable => \$count)->pack(-side => 'left');
$count的变化会立刻显现出来
-bitmap
$mw->Button(-bitmap => 'error', -command => \&handle_error)->pack;
很多内置bitmap
-image
$image = $mw->Photo(-file => "bigredbutton.gif");
$mw->Button(-text => 'Exit', -command => sub { exit },
-image => $image)->pack;
使用image必须先创建image widget,如果text和image同时被指定,只会出现image。
-state => "normal" "disabled" "active"
disable一个button
-relief => 'flat''groove''raised''ridge''sunken''solid'
普通凹槽突出突出的边框凹陷实线边框
-width => x, -height => y
改变button大小
-underline => N
在text的第n个字母下划线
$b->configure/$b->cget
$state = $button->cget(-state);
$text = $button->cget(-text);
configure用来配置button显现
cget用来获得选项值
$button->invoke( );
运行button的command指定函数

没有评论:
发表评论