Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying variable values in a text box 1

Status
Not open for further replies.

anirban2k2001

Programmer
Aug 25, 2003
27
IN
Hi all,

I have a text box where I want to display some variable values that I had fetched from a text file. Can anyone help me with the syntax in this respect. For convenience, I am giving the tcl code that I had used to generate the text box:

#label
label .l -text "Cons No" -font $fnt9
place .l -x 0 -y 10 -width 200 -height 10

#text box
text .t -bd 1 -highlightbackground black highlightthickness 1
place .t -x 150 -y 8 -width 70 -height 16
focus .t

Assuming that the Cons no. is in a variable $cons, how do I place the variable content in the text box?

Any help in this regard will be highly appreciated.
Thanks in advance.
 
The simplest form (I think) is:
.t insert end $cons
That places the current value of "cons" at the end of whatever is in the textbox. You can also use:
.t insert end $cons\n
to make sure that each entry is on a separate line.

There are (slightly) more complicated insertions using line number (say "l_no") and character number (say "c_no"):
.t insert $l_no.$c_no $cons[b/]
or pixel coordinates x and y:
.t insert @$x,$y $cons

Alternatively, have you considered a listbox? Using the -listvariable option, you can associate the contents of a listbox with a Tcl list, then update the list with $cons.

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top