Insert value to list box : Listbox « GUI « Perl






Insert value to list box

   

use Tk;

$main = MainWindow->new();

$listbox1 = $main->Listbox("-width" => 25, 
    "-height" => 5
)->pack;

$listbox1->insert('end', "Apples", "Bananas",
    "Oranges", "Pears", "Pineapples");

$listbox1->bind('<Double-1>', \&getfruit);

$text1 = $main->Text ('-width'=> 40, '-height' 
    => 2
)->pack;

sub getfruit {
    $fruit = $listbox1->get('active');
    $text1->insert('end', "$fruit ");
}

MainLoop;

   
    
    
  








Related examples in the same category

1.Add list box to a window
2.Bind double click action to the list box
3.Using Scroll Bar to control a list box
4.Fill data to a list box