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!

listbox problem 1

Status
Not open for further replies.

stewang

Programmer
Aug 21, 2003
77
NZ
Hello all:
I want to bring up a new window with a list box by click a button.
but I do not why my code can not work. Would anyone help me, please.
Code:
button .b -text "button" -bg white      -command newWindow
pack .b

proc newWindow {} {
 toplevel .t

 set lv {'test" "test"}

 frame .listframe  
 listbox .listframe.namelist -listvariable lv \ 
 pack .t.listframe.namelist -side top

}
 
1/ You have to make the frame a child of the toplevel (.t.listframe)
2/ You need to pack the frame, too.
3/ You must not tie together independant commands (don't have to add a back slash)
4/ The lv variable referenced by the -listvariable option is a global variable. Not the local variable initialized by newWindow. So you need to make lv global. Either with the global command or by used the :: syntax has I do.
5/ You made a typo: 'text" should be "text".
Code:
  proc newWindow {}   {
    toplevel .t
    set ::lv {"test" "test"}
    frame .t.listframe
    listbox .t.listframe.namelist -listvariable ::lv
    pack .t.listframe.namelist -side top
    pack .t.listframe
  }
HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top