#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new; $mw->title("Listbox"); # For example purposes, we will use one word for each letter my @choices = qw/alpha beta charlie delta echo foxtrot golf hotel india juliet kilo lima motel nancy oscar papa quebec radio sierra tango uniform victor whiskey xray yankee zulu/; #Create the text box and insert the list of choices in to it my $lb = $mw->Scrolled("Listbox", -scrollbars => "osoe", -height => 10, -width => 10, -selectmode => "multiple"); my $real_lb = $lb->Subwidget('scrolled'); $real_lb->configure(-borderwidth=>0); $lb->insert("end", sort @choices); $lb->pack(-side => "left"); $mw->Button(-text => "Exit", -command => sub{exit; })->pack(-side => "bottom"); $mw->Button(-text=>"View", -command => sub { foreach ($lb->curselection()) { print "$choices[$_]\n"; } my $w = $real_lb->width; print "$w\n"; my $sample = ' ' x 10; my $font_len = $lb->fontMeasure('default', $sample ); print "$font_len\n"; } )->pack(-side => "bottom"); $lb->selectionSet('end'); $lb->see('end'); MainLoop;