滚动条小部件是无需文本或画布小部件即可工作的滚动小部件。滚动条小部件的语法如下所示。
scrollbar scrollbarName options
下表列出了可用于滚动条小部件的选项。
链接:https://www.learnfk.comhttps://www.learnfk.com/tcl-tk/tk-scrollbar-widget.html
来源:LearnFk无涯教程网
Sr.No. | Syntax & Remark |
---|---|
1 | -background color 用于设置小部件的背景颜色。 |
2 | -borderwidth width 用于在3D效果中使用边框绘制。 |
3 | -orien orientation 设置小部件的方向。它可以是水平或垂直的。 |
4 | relief condition 设置此小部件的3D浮雕。 |
5 | -relief condition 命令链接视图到滚动条小部件。 |
滚动条小部件的一个简单示例如下所示-
#!/usr/bin/wish grid [tk::listbox .l -yscrollcommand ".s1 set" -xscrollcommand ".s2 set" -height 5 -width 20] -column 0 -row 0 -sticky nwes grid [ttk::scrollbar .s1 -command ".l yview" -orient vertical -background yellow -borderwidth 5 -relief ridge] -column 1 -row 0 -sticky ns grid [ttk::scrollbar .s2 -command ".l xview" -orient horizontal -background yellow -borderwidth 5 -relief ridge] -column 0 -row 1 -sticky ew for {set index 0} {$index<100} {incr index} { .l insert end "A long line of text for testing scrollbar." }
当无涯教程运行上面的程序时,将获得以下输出-
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)