in reply to TK ListBox Scrolling
#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: TK ListBox Scrolling
by SteveS832001 (Sexton) on Mar 06, 2008 at 16:16 UTC | |
|
Re^2: TK ListBox Scrolling
by Anonymous Monk on Feb 08, 2011 at 21:47 UTC | |
by Anonymous Monk on Feb 10, 2011 at 10:34 UTC |