Hello,
Does anyone know how to do the following:
I have a problem when I want to Select some listbox item in different
listbox in the same time together. I have found a code and make a little
changing to the code. In that code there are 3 listbox with different
item, when I select the first item (first listbox), the selection is
only show in the third item (in the third listbox), whereas I want to
make all of the third item in the same row in that three different
listbox selected together.
Here is mycode :
require ‘tkextlib/tile’
$countrycodes = %w{ ar au be br ca cn dk fi fr gr in it jp mx nl no es
se ch }
$countrynames = %w{ Argentina Australia Belgium Brazil Canada China
Denmark
Finland France Greece India Italy Japan Mexico Netherlands
Norway Spain
Sweden Switzerland}
$nomor = %w{ 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15 16 17
18 19}
$names = TkVariable.new ( $countrynames )
$kode = TkVariable.new ( $countrycodes )
$no = TkVariable.new ( $nomor )
root = TkRoot.new
content = Tk::Tile::Frame.new(root) {padding “5 5 12 0”}.grid :column =>
0, :row => 0, :sticky => “nwes”
TkGrid.columnconfigure root, 0, :weight => 1
TkGrid.rowconfigure root, 0, :weight => 1
$countries = TkListbox.new(content) {listvariable $names; height
5;selectmode ‘multiple’}
$kode = TkListbox.new(content) {listvariable $kode; height 5;selectmode
‘multiple’}
$no = TkListbox.new(content) {listvariable $no; height 5l;selectmode
‘multiple’}
$countries.grid :column => 0, :row => 0, :rowspan => 6, :sticky =>
‘nsew’
$kode.grid :column => 1, :row => 0, :rowspan => 6, :sticky => ‘nsew’
$no.grid :column => 2, :row => 0, :rowspan => 6, :sticky => ‘nsew’
TkGrid.columnconfigure content, 0, :weight => 1
TkGrid.rowconfigure content, 5, :weight => 1
$countries.bind ‘’, proc{pilihAnggota}
def pilihAnggota
idx = $countries.curselection
$kode.selection_set idx
$no.selection_set idx
end
Colorize alternating lines of the listbox
0.step($countrycodes.length-1, 2) {|i| $countries.itemconfigure i,
:background, “#f0f0ff”}
0.step($countrycodes.length-1, 2) {|i| $kode.itemconfigure i,
:background, “#f0f0ff”}
0.step($countrycodes.length-1, 2) {|i| $no.itemconfigure i, :background,
“#f0f0ff”}
$countries.selection_set 0
#showPopulation
Tk.mainloop
================================================================
Thank’s for your help.