Oguni, Toshi S wrote:

How do I move selections from a listbox in a window (Toplevel2) and add them to a listbox in another window (Toplevel1).

Run and study the example until you understand it completely.

-- Luke Kale Myers

#!/bin/sh
# the next line restarts using wish\
exec wish "$0" "$@"

wm withdraw .


toplevel .t1
listbox .t1.l -selectmode extended
button .t1.b -text "Move selected item(s)" \
-command {moveSelected .t1.l .t2.l}
pack .t1.l .t1.b

toplevel .t2
listbox .t2.l -selectmode extended
button .t2.b -text "Move selected item(s)" \
-command {moveSelected .t2.l .t1.l}
pack .t2.l .t2.b

.t1.l insert end [EMAIL PROTECTED]
.t1.l insert end [EMAIL PROTECTED]
.t1.l insert end someuser@somedomain

.t2.l insert end "2 + 2 = 4"
.t2.l insert end "2 x 2 = 4"
.t2.l insert end "4 = 2(2)"

# move the selected items from the source
# listbox to the target listbox
#
proc moveSelected { source target } {
set indices [ $source curselection ]

if { [ llength $indices ] == 0 } {
return
}

foreach item $indices {
set content [ $source get $item ]
$target insert end $content
}

set firstItem [ lindex $indices 0 ]
set lastItem [ lindex $indices end ]

$source delete $firstItem $lastItem

}




-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/vtcl-user


Reply via email to