如何在 Tktable 中将某些列设置为左对齐?
How to set some columns as left justifying in the Tktable?
是否可以将某些列设置为左对齐?例如:
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 configure -anchor w”,这使得所有列都左对齐...
你必须为此使用标签。在你的例子中
.table tag col left 2 3
将指定的标记 left
添加到第 2 列和第 3 列(Center_X
和 Width_X
)。那么
.table tag configure left -anchor w
left-justifies 他们。如果您希望标题居中,请添加
.table tag configure title -anchor c
(title
是标题单元格的预定义标签)。
是否可以将某些列设置为左对齐?例如:
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 configure -anchor w”,这使得所有列都左对齐...
你必须为此使用标签。在你的例子中
.table tag col left 2 3
将指定的标记 left
添加到第 2 列和第 3 列(Center_X
和 Width_X
)。那么
.table tag configure left -anchor w
left-justifies 他们。如果您希望标题居中,请添加
.table tag configure title -anchor c
(title
是标题单元格的预定义标签)。