我在不同的框架和一些绑定中创建了Nehmeti的两个不同的表格。
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]
这两个表格列表后面都有内容。列中的数字&#34; oid&#34; in pfd(tali_mw)对应于列&#34; oid&#34;中的数字。在pfd(tali_klaff)。
现在我想在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
}
.
.
.
论证&#34; oidbez&#34;是两个表格列表中第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)中激活相应的行。不幸的是,focus命令会阻止tablelist的绑定命令,例如我无法在pfd(tali_klaff)中双击。
接下来我会尝试选择pfd(tali_mw)中的行,然后只更改pfd(tali_klaff)中相应行的背景。但我想避免这种方式。是否有可能在两个表格列表中选择两行?我必须支持两个表列表,因为它们还有其他功能。谢谢你的帮助。
答案 0 :(得分:1)
您应该在两个表格列表(-exportselection 0
)中关闭选择的导出,否则在一个列表中选择一个内容将阻止您在另一个列表中选择一个内容。该选项引用的选择是PRIMARY
选择,并且一次只能由一个窗口小部件保存(除非您使用selection
命令做一些聪明的事情来呈现更复杂的模型)。
您可能还需要为<<Cut>>
,<<Copy>>
以及可能的<<Paste>>
(虚拟)事件添加自己的绑定,具体取决于您正在做什么。或者你可能在你的应用程序中合理地不关心它们。那真是太棒了......