This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to get value displayed in entry field of the window


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]