如何在Tcl中使TableList可滚动?

时间:2015-11-08 23:02:22

标签: tcl tk

我正在使用tablelist包在一个框架中显示一个表列表(heh),但框架非常小,表中有一堆列。

我需要一些方法来使这个表格可以水平和垂直滚动。

这是我的表格列表的代码

labelframe .t.lbf -text "Search Results for: $term" -padx 0 -width 47

tablelist::tablelist .t.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} -stretch all -background white -width 47                

pack .t.mlb  -in .t.lbf -anchor w

place .t.lbf -x 10 -y 125

1 个答案:

答案 0 :(得分:0)

我已经发布了向窗口小部件添加滚动条的基本方法(在本例中为文本窗口小部件)here。以下似乎有效:

toplevel .t
labelframe .t.lbf -text "Search Results for: $term" -padx 0 -width 47
tablelist::tablelist .t.lbf.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} -stretch all -background white -width 47 -xscroll {.t.lbf.h set} -yscroll {.t.lbf.v set}

scrollbar .t.lbf.v -orient vertical   -command {.t.lbf.mlb yview}
scrollbar .t.lbf.h -orient horizontal -command {.t.lbf.mlb xview}

# Lay them out
grid .t.lbf -sticky nsew

grid .t.lbf.mlb .t.lbf.v -sticky nsew
grid .t.lbf.h            -sticky nsew

# Tell the tablelist widget to take all the extra room
grid rowconfigure    .t.lbf .t.lbf.mlb -weight 1
grid columnconfigure .t.lbf .t.lbf.mlb -weight 1

place .t.lbf -x 10 -y 125

其他读者请注意:OP希望将tablelist包裹在labelframe中,然后place。没有这些要求,任务变得更容易一些。再次,请参阅上面链接中的我的示例:将其重新用于表列表只涉及替换文本小部件。

文档:gridlabelframeplacescrollbartoplevel

相关问题