如何在Tktable中将一些列设置为左对齐?

时间:2017-11-29 03:22:24

标签: tcl tk

是否可以将某些列设置为左对齐?例如:

package require Tktable
table .table -rows 3 -cols 4 -titlerows 1 -titlecols 1
global TableValue
array set TableValue {0,1 Title 0,2 Center_X 0,3 Width_X 1,0 1 2,0 2 \
1,1 test1 1,2 0.5 1,3 0.2 2,1 test2 2,2 0.8 2,3 0.3}
.table configure -variable TableValue
pack .table

如果我只想设置" Center_X"和" Width_X"左派合理,怎么做? 我已经尝试过" .table conifgure -anchor w",这使得所有列都不合理......

1 个答案:

答案 0 :(得分:1)

你必须使用标签。在你的例子中

.table tag col left 2 3

将指定的标记left添加到第2列和第3列(Center_XWidth_X)。然后

.table tag configure left -anchor w

左对齐他们。如果您希望标题居中,请添加

.table tag configure title -anchor c

title是标题单元格的预定义标记。)