我在Nehmeti中創建了兩個不同的表格列表,分別是不同的框架和一些綁定。Tcl Tk在兩個不同的表格列表中選擇行
set pfd(panWin) [panedwindow $pfd(bottomFr).pw -showhandle 1 -orient vertical -sashpad 0 -sashrelief raised -sashwidth 2]
set pfd(frMesswerte) [frame $pfd(panWin).frMesswerte]
set pfd(frKlaffNeupkt) [frame $pfd(panWin).frKlaffNeupkt]
set pfd(noteb) [iwidgets::notebook $pfd(frKlaffNeupkt).noteb]
pack $pfd(noteb) -anchor nw -expand 1 -fill both
set pfd(frKlaffungen) [$pfd(noteb) add -label Klaffungen]
set pfd(tali_mw) [tablelist::tablelist $pfd(frMesswerte).li.tali_mw \
-columns {0 "oid" l \
0 "status" l \
0 "art" l \
0 "sollTyp" l \
0 "Nr" l \
0 "Typ" l \
0 "Gst" l \
0 "Hz" r \
0 "V" r \
0 "S" r \
0 "Q" r \
0 "L" r \
0 "AK" l\
0 "LSEX" l \
0 "lfdNrGes" l}\
-exportselection 1 \
-labelbackground #EEEEEE \
-background white \
-labelfont $tableheadfont\
-font $tableinhfont\
-stretch 12\
-selectbackground $vmVConfig::setVar(activeBG) \
-selectforeground $vmVConfig::setVar(activeFG) \
-selectmode single\
-borderwidth 1 \
-labelborderwidth 1 \
-selectborderwidth 0 \
-tooltipaddcommand [::itcl::code $this tooltipAddCmd] \
-tooltipdelcommand [::itcl::code $this tooltipDelCmd] \
-xscrollcommand [list vmTkTools::configSB "h" $pfd(mw_scrx)]\
-yscrollcommand [list vmTkTools::configSB "v" $pfd(mw_scry)]]
set body [$pfd(tali_mw) bodypath]
bind $body <Double-1> +[::itcl::code $this doubleKlickMesswerte %x %y %W]
bind $body <Button-1> +[::itcl::code $this loeschePfeil]
bind $body <Button-3> +[bind TablelistBody <Button-1>]
bind $body <Button-3> +[::itcl::code $this popUp $pfd(popUpMenu) %X %Y]
set pfd(tali_klaff) [tablelist::tablelist $pfd(frKlaffungen).li.tali_klaff \
-columns {0 "oid" l 0 "Nr" l 0 "dX" r 0 "dY" r 0 "GwX" r 0 "GwY" r 0 "Rdz" r}\
-labelbackground #EEEEEE \
-background white \
-labelfont $tableheadfont\
-font $tableinhfont\
-stretch 7\
-selectbackground $vmVConfig::setVar(activeBG) \
-selectforeground $vmVConfig::setVar(activeFG) \
-selectmode single\
-labelrelief groove \
-borderwidth 1 \
-labelborderwidth 1 \
-selectborderwidth 0 \
-xscrollcommand [list vmTkTools::configSB "h" $pfd(klaff_scrx)]\
-yscrollcommand [list vmTkTools::configSB "v" $pfd(klaff_scry)]]
set body [$pfd(tali_klaff) bodypath]
bind $body <Double-1> +[::itcl::code $this anzeigePpMp4Klaff]
bind $body <Button-3> +[bind TablelistBody <Button-1>]
bind $body <Button-3> +[::itcl::code $this popUp $pfd(popUpKlaffungen) %X %Y]
這兩個表格列表後面填滿了內容。 pfd(tali_mw)中的「oid」列中的數字對應於pfd(tali_klaff)中的「oid」列中的數字。
現在我想選擇在PFD的行(tali_mw)和PFD(tali_klaff)被選擇相應的行
我寫了下面的方法。
itcl::body vmMaskHelmert::selPPorMPinTableMWKLAFF {oidbez id} {
foreach tag [$data(canRef) gettags $id] {
if {[string range $tag 0 7] == "PASSPKT_"} {
set art "pass"
} elseif {[string range $tag 0 7] == "MASSPKT_"} {
set art "masse"
}
}
set inhaltMW [$pfd(tali_mw) get 0 end]
set idx 0
$pfd(tali_mw) selection clear 0 end
foreach zeile $inhaltMW {
set ken [lindex $zeile 0]
if { [string compare $ken $oidbez] == 0 } {
set rowMW $idx
break
}
incr idx
}
set inhaltKLAFF [$pfd(tali_klaff) get 0 end]
set idx 0 ; # Zaehler welche Zeile
$pfd(tali_klaff) selection clear 0 end
foreach zeile $inhaltKLAFF {
set ken [lindex $zeile 0]
if { [string compare $ken $oidbez] == 0 } {
set rowKLAFF $idx
break
}
incr idx
}
.
.
.
參數「oidbez」是兩個表中的第0列的oid。
首先,我想繼續這樣的:
$pfd(tali_mw) selection set $rowMW $rowMW
$pfd(tali_klaff) selection set $rowKLAFF $rowKLAFF
return
}
但在PFD(tali_mw)選擇被帶走。
所以我試過如下:
$pfd(tali_mw) selection set $rowMW $rowMW
$pfd(tali_klaff) activate $rowKLAFF
focus $pfd(tali_klaff)
return
}
現在我看到在PFD(tali_mw)選定的行和相應的行PFD(tali_klaff)激活。不幸的是,焦點命令會阻止列表中的綁定命令,例如我無法在pfd(tali_klaff)中進行任何雙擊。
接下來,我會嘗試選擇pfd(tali_mw)中的行,並只更改pfd(tali_klaff)中相應行的背景。但我想避免這種方式。有沒有可能在兩個列表中選擇兩行?我必須維護兩個列表,因爲它們還有其他功能。感謝您的幫助。