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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox problem

Status
Not open for further replies.

fabien

Technical User
Sep 25, 2001
299
AU
Hi!

I would like to read some data from an ASCII file like
tutu
toto
ttata

and display the each element in a listbox ($list)

If I do
set fd [open $listf "r"]
set data [read $fd]
set filessel [split data "\n"]

$list insert end $filessel

I get
tutu toto tata {}

two questions:
1) how can I display the data in the listbox like
tutu
toto
tata

2) remove {} (is it like a blank char?)

Thanks!
 
$filessel is a list that the listbox inserted as a sole element whose value was: {tutu toto tata}.

You can try:
Code:
eval $list insert end $filessel
or better (eval has some subtilities):
Code:
eval [linsert $filessel 0 $list insert end]
or (more readable):
Code:
foreach item $filessel {$list insert end $item}

bonne chance !

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top