如何使控件 "previous" 和 "next" 移动比例小部件滑块?
How to make controls "previous" and "next" move a scale widget slider?
我正在为具有所有标准控件的桌面播放器开发用户界面。我想做一个相同风格的音量控制器:
代码简单,就是我的esbo:
#!/bin/sh
# \
exec wish "[=12=]" "$@"
. configure -width 100 -height 50
pack [button .btn1 -text "-" -command { bell }] -side left -fill none
pack [scale .scl0 -showvalue 1 -from 0 -to 10 -resolution 1 -orient horizontal] -side left -fill both
pack [button .btn2 -text "+" -command { bell }] -side right -fill none
这就是我到目前为止的全部内容。我不知道如何通过按下按钮来移动秤,使其从左到右和从右到左。
您只需要为比例分配一个变量,然后是一个修改该变量的过程。例如:
pack [button .btn1 -text "-" -command {volume -1}] -side left -fill none
pack [scale .scl0 -showvalue 1 -from 0 -to 10 -resolution 1 -orient horizontal \
-variable currentVolume] -side left -fill both
pack [button .btn2 -text "+" -command {volume 1}] -side left -fill none
proc volume {val} {
incr ::currentVolume $val
}
我正在为具有所有标准控件的桌面播放器开发用户界面。我想做一个相同风格的音量控制器:
代码简单,就是我的esbo:
#!/bin/sh
# \
exec wish "[=12=]" "$@"
. configure -width 100 -height 50
pack [button .btn1 -text "-" -command { bell }] -side left -fill none
pack [scale .scl0 -showvalue 1 -from 0 -to 10 -resolution 1 -orient horizontal] -side left -fill both
pack [button .btn2 -text "+" -command { bell }] -side right -fill none
这就是我到目前为止的全部内容。我不知道如何通过按下按钮来移动秤,使其从左到右和从右到左。
您只需要为比例分配一个变量,然后是一个修改该变量的过程。例如:
pack [button .btn1 -text "-" -command {volume -1}] -side left -fill none
pack [scale .scl0 -showvalue 1 -from 0 -to 10 -resolution 1 -orient horizontal \
-variable currentVolume] -side left -fill both
pack [button .btn2 -text "+" -command {volume 1}] -side left -fill none
proc volume {val} {
incr ::currentVolume $val
}