in reply to Re^3: tk::matchentry changing the displayed choices
in thread tk::matchentry changing the displayed choices

ok. that works but theres a but. i have a list of approx 16000 place names to populate this listbox with and with that many its quite slow. so i thought i would break it down and have 26 lists (one for each letter of the alphabet) and then load the appropriate one once i knew what the first letter was - Daniel
  • Comment on Re^4: tk::matchentry changing the displayed choices

Replies are listed 'Best First'.
Re^5: tk::matchentry changing the displayed choices
by GrandFather (Saint) on Jan 21, 2008 at 23:20 UTC

    It passed through my mind that that was what you were after. The following is probably what you want:

    use strict; use warnings; use Tk; use Tk::MatchEntry; my %data = ( a => [qw/Abberley Abberton Abbotsley Accrington/], b => [qw/Babraham Bacton Bexhill Bradfield/] ); my $place; my $mw = MainWindow->new (-title => "i wish this would work",); $mw->geometry ("200x70+0+0"); my $label = $mw->label ("type somthing in the box"); my $me = $mw->MatchEntry ( -textvariable => \$place, -choices => [keys %data], -autosort => 0, -fixedwidth => 0, -ignorecase => 1, -maxheight => 10, -listwidth => 240, -onecmd => \&repopulate, )->pack (-side => 'left'); Tk::MainLoop (); sub repopulate { return unless exists $data{lc $place}; $me->configure (-choices => $data{lc $place}); }

    Perl is environmentally friendly - it saves trees
      well played that man! Thank you i wouldnt have been able to guess that in years. the only bit i dont understand is whats the lc in $data(lc $place)?

        lc returns the lower case version of the string in $place. Your list is not case sensitive so the keys in the hash need to be not case sensitive. Forcing them to lc (or uc) achieves that.


        Perl is environmentally friendly - it saves trees