treectrl中的列跨越

时间:2019-04-16 10:58:32

标签: tcl tk

我要根据treectrl中字符串的长度来划分一些列,并希望在第一列附近显示第三列。

我通过tktreectrl创建了一个小树。

在其中,我创建了一些列:

(树是树小部件的路径名)

set columnID colItem
set columnID2 colzwei
set columnID3 coldrei
set columnID4 colvier
set columnID5 colfuenf
set columnID6 colsechs

$tree column create -expand no -weight 1 -text "Ergebnis:" -tags colItem -font $fontArr(font:12bold) -borderwidth 1
$tree column create -expand no -weight 4 -text "2" -tags colzwei -borderwidth 1 -font $fontArr(font:12bold) -uniform a -width 15
$tree column create -expand no -weight 4 -text "3" -tags coldrei -borderwidth 1 -font $fontArr(font:12bold) -uniform a 
$tree column create -expand no -weight 4 -text "4" -tags colvier -borderwidth 1 -font $fontArr(font:12bold) -uniform a -width 15
$tree column create -expand yes -weight 4 -text "5" -tags colfuenf -borderwidth 1 -font $fontArr(font:12bold) -uniform a 
$tree column create -expand yes -weight 4 -text "6" -tags colsechs -borderwidth 1 -font $fontArr(font:12bold) -uniform a

这些列应填充多个数据。

我想要的是,跨度的行为取决于给定文本的长度。

(txt1和txt2由另一个函数给出,看起来像这样:

txt 1:Grünland-Acker(GrA),Lehmiger Sand(lS),Bodenstufe(II),Wasserstufe(3),Klimastufe 7.9°-7.0°C(b),Grünlandgrundzahl33,Grünlandzahl29

txt2:1610平方米)

set itemID [$tree item create -button auto -tags $zel]

。 。

if {[string length $txt1] > 100} {
    $tree item span $itemID colItem 3
    $tree item span $itemID colfuenf [$tree column count]
} else {
    $tree item span $itemID coldrei [$tree column count]
}

Later I configure the text:
if {[string length $txt1] > 100} {
    $tree item style set $itemID $columnID styAny $columnID5 styAny
    $tree item text $itemID $columnID $txt1 $columnID5 $txt2
} else {
    $tree item style set $itemID $columnID styAny $columnID3 styAny
    $tree item text $itemID $columnID $txt1 $columnID3 $txt2
}
$tree item element configure $itemID $columnID elemTxtName -font [list $fontArr(font:12normal) {}] -justify right

如果打开了长文本树的一部分,则第三列(coldrei)中的数据将显示一些空格。如果我关闭树的这一部分,则第三列中的数据将接近第一列(如预期的那样,仅第二行的15个像素)。 即使打开了包含长数据的树部分,如何将第三列靠近第一列?

这是打开长文字的部分的外观(在本例中为“Bodenschätzung”)

enter image description here

这就是关闭“Bodenschätzung”按钮时的外观。 enter image description here

因此,我希望其他项目在txt1和txt2之间始终具有相同的空间,而无论“Bodenschätzung”按钮是打开还是关闭。我该怎么办?

0 个答案:

没有答案