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

Listbox in a notebook to a listbox

Status
Not open for further replies.

y9john

Programmer
Jan 27, 2011
2
Hi everyone I am working on a gui for the program I am making. I have a window that has notebook with a listbox imbedded in each tab. I am currently trying to get the selection in the tabbed listbox to show up in a listbox I have outside the notebook. I can get it working by binding the double click of the mouse to do it but it keeps erroring out when I try using the button press. I was wondering if anyone has any suggestions for getting it working. Below is the line for the button and the double click.

Double
bind $bw.commands.niagara.box <Double-1> [list ::CILSUITE::ListTransferSel %W $bw.new_script]

Button
grid [ttk::button $bw.add_button -text "Add ->"] -column 9 -row 3
$bw.add_button configure -command [::CILSUITE::ListTransferSel %W $bw.new_script]

List Transfer Sel Proc

proc ListTransferSel {src dst} {

foreach i [$src curselection] {

$dst insert end [$src get $i]

}

}

Note book and listbox code

grid [ttk::notebook $bw.commands -style System.TNotebook] -columnspan 5 -rowspan 10 -sticky nwes

ttk::frame $bw.commands.niagara
$bw.commands.niagara configure -borderwidth 2
ttk::frame $bw.commands.f2
$bw.commands.f2 configure -borderwidth 2
$bw.commands add $bw.commands.niagara -text "niagara"
$bw.commands add $bw.commands.f2 -text "HP"

grid [tk::listbox $bw.commands.niagara.box -yscrollcommand "$bw.commands.niagara.box_bar set" -selectmode extended -height 5] -column 0 -row 0 -rowspan 5 -columnspan 5 -sticky nwes
grid [ttk::scrollbar $bw.commands.niagara.box_bar -command "$bw.commands.niagara.box yview" -orient vertical] -column 6 -row 0 -rowspan 5 -sticky ns

grid [tk::listbox $bw.commands.f2.box -yscrollcommand "$bw.commands.f2.box_bar set" -selectmode extended -height 5] -column 0 -row 0 -rowspan 5 -columnspan 5 -sticky nwes
grid [ttk::scrollbar $bw.commands.f2.box_bar -command "$bw.commands.f2.box yview" -orient vertical] -column 6 -row 0 -rowspan 5 -sticky ns

grid [tk::listbox $bw.new_script -yscrollcommand "$bw.new_script_bar set" -selectmode extended -height 5] -column 11 -row 0 -columnspan 5 -rowspan 10 -sticky nwes
grid [ttk::scrollbar $bw.new_script_bar -command "$bw.new_script yview" -orient vertical] -column 17 -row 0 -rowspan 10 -sticky ns


Any help would be appreciated. Also if I didn't post it right or something to that effect, just let me know and I will fix it.
Thank you.
 
For starters, the 2 commands are different:
Code:
Double
bind $bw.commands.niagara.box <Double-1> [list ::CILSUITE::ListTransferSel %W $bw.new_script]

Button
grid [ttk::button $bw.add_button -text "Add ->"] -column 9 -row 3
$bw.add_button configure -command [::CILSUITE::ListTransferSel %W $bw.new_script]

In the binding, you have [list ...]] and in the button option you have [...]. Now, the list command will make a list out of the subsequent arguments:
Code:
% list a b c d
a b c d
%
I am not clear what you're trying to accomplish but it seems like if you want a list, you need to say that.



_________________
Bob Rashkin
 
Hi Bob,

What I am trying to do is grab the current selection in any listbox in the notebook that is active and move it to the listbox that isn't in the notebook. i can get it to work with just one listbox to another but I can't seem to get it to work without it. I am trying to do it as robust as possible so I don't have to code in the functionality for each box I want to use. I guess my question is, is there a command that will grab the current selection in the currently active listbox?

Thank you
John
 
$w curselection

where "w" is the path to the listbox

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top