This is the mail archive of the
insight@sources.redhat.com
mailing list for the Insight project.
Re: how to get value displayed in entry field of the window
- From: Keith Seitz <keiths at redhat dot com>
- To: KiranKumar B Shivananda <kirankumar dot shivananda dot b at celstream dot com>
- Cc: Hans Kester <hans at ellips dot nl>, "insight at sources dot redhat dot com" <insight at sources dot redhat dot com>
- Date: Wed, 01 Dec 2004 11:10:41 -0800
- Subject: Re: how to get value displayed in entry field of the window
- References: <80464F9A4D2BF042A154DD067F1F539302A63E7F@CEL-BANGT-M01>
On Mon, 2004-11-22 at 20:23, KiranKumar B Shivananda wrote:
> In .itb file
>
> I am doing like this
>
> $_regf.value$regnum config -textvariable RegWin::_value($regnum)
You must remember that you are not using "vanilla" tcl and tk. Insight
is written in Itcl, and you must follow the conventions of that
extension.
Your problem is that you cannot pass variable names as-is to tcl/tk
objects. You MUST use the scope keyword to specify the object's "scope".
Here is an example of how to do this:
---------- copy to a file and source the file in wish8.4 --------
package require Itcl
package require Itk
itcl::class Entry {
inherit itk::Widget
private variable _foo {unset}
constructor {args} {
itk_component add entry {
entry $itk_interior.entry -textvariable [itcl::scope _foo]
}
pack $itk_component(entry)
}
public method setValue {value} { set _foo $value }
}
set entry .a
Entry $entry
pack $entry
$entry setValue "This is the proper way to do this"
------------------ end of file -------------------
As you can see, I've used the "itcl::scope" to tell the Tk entry widget
the proper "path" to the real variable. See scope(n) for details.
Keith