求教一个laker下的tcl程序问题
Set addLoc [gtCreateButton -name addSymbol -buttonText “Add Location”\
-callback {for {set a 1} {$a <= 7} {incr a 1} {
Set location($a) [gtCreatePointField -name Location($a)\
-editable t\
-prompt “Location”\
-value (0,0)\
-defValue (0,0) ]
gtAddFields –handle $form –fields [ list $location($a)]}}]
set form [gtCreateAppForm -name Form\
-title "Form:"
-buttonLayout OKCancelDefApply
-fields [list $addLoc]
-callback {for {set a 1} {$a <= 7} {incr a 1} {
set data $Form(Location($a):value)
puts "$data"}}]
getDisplay -handle $form
结果报错,*GuiTcl* Error: can't read "Form(Location(1)": no such element in array.
请问这个问题应该如何解决呢?
好久没用laker了,看了一下,觉得这一句:
gtAddFields –handle $form –fields [ list $location($a)]}}]
应该放在这一句:
getDisplay -handle $form
的前面。即最后几行应该这样:
set form [gtCreateAppForm -name Form\
-title "Form:"
-buttonLayout OKCancelDefApply
-fields [list $addLoc]
-callback {for {set a 1} {$a <= 7} {incr a 1} {
set data $Form(Location($a):value)
puts "$data"}}]
gtAddFields –handle $form –fields [ list $location($a)]}}]
getDisplay -handle $form
谢谢楼上的帮助了,问题是,如果将gtAddFields –handle $form –fields [ list $location($a)]放在getDisplay -handle $form后面的话,那么前面
Set addLoc [gtCreateButton -name addSymbol -buttonText “Add Location”\
-callback {for {set a 1} {$a <= 7} {incr a 1} {
Set location($a) [gtCreatePointField -name Location($a)\
-editable t\
-prompt “Location”\
-value (0,0)\
-defValue (0,0) ]}]
的执行按钮就无法callback一个可见的PointField
等高手解决...
弱弱的问一句,请问小编解决了么?