Dear GiD-Team,
I am using several Tkwidgets to process user input. Consider the following simple example .prb below:
PROBLEM DATA
TITLE: Something
QUESTION: Some_Question
VALUE: 0
TKWIDGET: Some_Widget
END PROBLEM DATA
Some_Widget only opens a tcl window showing the given Value:
proc Some_Widget {event args} {
switch $event {
SYNC {
CreateErrorWindow [GiD_AccessValue get gendata Some_Question]
return
}
}
}
If I now enter a value (lets say 2) for Some_Question and press accept the Widget is called but the windows still shows 0. Only if I press Accept a second time, the right value (2) is shown. This means for me, that GiD somehow first updates the Value but with GiD_AccessValue I still access the old value. Is there another way to access the already updated value on pressing Accept the first time?
Greeting,
barnacle
Tkwidgets and field value updating
Moderator: GiD Team
Re: Tkwidgets and field value updating
GiD_AccessValue access to the true internal value of the field.
The window field store a temporary copy of this field, the internal value is updated from this copy when the user press 'Accept'
you can use our procedures DWLocalGetValue , DWLocalSetValue to get and set the temporary copy of the field
The TKWIGDET registered procedure is invoked with a first argument that could be: INIT, SYNC, DEPEND, CLOSE
and a variable argument args that provide extra information needed to know the current item data
I don't recommend you to write your own TKWIDGET procedures if they are not really needed to enhance your application.
Have a look to our file scripts/dev_kit.tcl, it has a collection of some predefined TKWIDGET procedures for common situations, named proc GidUtils::Tkwidget...
use them if possible, instead of create your similar procedure.
http://www.gidhome.com/component/manual ... s/tkwidget
The window field store a temporary copy of this field, the internal value is updated from this copy when the user press 'Accept'
you can use our procedures DWLocalGetValue , DWLocalSetValue to get and set the temporary copy of the field
The TKWIGDET registered procedure is invoked with a first argument that could be: INIT, SYNC, DEPEND, CLOSE
and a variable argument args that provide extra information needed to know the current item data
Code: Select all
proc Some_Widget {event args} {
switch $event {
INIT {
lassign $args PARENT current_row_variable GDN STRUCT QUESTION
upvar $current_row_variable ROW
set ::your_own_variable [DWLocalGetValue $GDN $STRUCT $QUESTION]
...
}
SYNC {
lassign $args GDN STRUCT QUESTION
if { [info exists ::your_own_variable] } {
DWLocalSetValue $GDN $STRUCT $QUESTION $::your_own_variable
}
}
DEPEND {
lassign $args GDN STRUCT QUESTION ACTION VALUE
#
}
CLOSE {
#release your own resources
}
}
}
I don't recommend you to write your own TKWIDGET procedures if they are not really needed to enhance your application.
Have a look to our file scripts/dev_kit.tcl, it has a collection of some predefined TKWIDGET procedures for common situations, named proc GidUtils::Tkwidget...
use them if possible, instead of create your similar procedure.
http://www.gidhome.com/component/manual ... s/tkwidget