Hi monks , i have written a script to select the items in the list-box (by double clicking on the item) ,simultaneously displaying selected items in another list. Here problem is how can i avoid the multiple selections. eg:In list-box iam "test1" get selected twice or more , in other-side it should not display the twice it should display only one item at a time. Can any one help me out of this problem please

#!/usr/binperl -w use strict; use warnings; use Tk; use Tk::LabFrame; use Tk::ROText; my $mw = MainWindow->new(); $mw->geometry("500x400"); my $f1 = $mw->LabFrame( -label => "List-box-selection", -font => 'ukai', -labelside => "acrosstop", )->pack(); my @list = (qw/test1 test2 test3 test4 test5/); my $lb = $f1->Scrolled( "Listbox", -scrollbars => "e", -selectmode => "extended", -font => 'ukai', -activestyle => "dotbox", )->pack(); $lb->insert( 'end', @list ); my $txt_scroll; $lb->bind( '<Double-1>' => sub { my $current_ip = $_[0]->get( $_[0]->curselection ); $txt_scroll->insert( 'end', "SELECTED IP : $current_ip\n" ); }, ); my $f2 = $mw->LabFrame( -label => "Commands Info", -font => 'ukai', -labelside => "acrosstop", )->pack(); $txt_scroll = $f2->Scrolled( 'ROText', -scrollbars => 'osoe', -height => 6, -width => 25, -font => 'ukai', )->pack(); $mw->update(); MainLoop;

In reply to How to avoid the duplicate selection in perl tk by vr786

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.