#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::MatchEntry;
use threads;
use threads::shared;
my %shash;
my %hash;
my @choices;
share $shash{'go'};
share $shash{'die'};
share @choices;
$shash{'go'} = 0;
$shash{'die'} = 0;
@choices = ( "01234", "345345", "64364" );
$hash{'thread'} = threads->new(\&work);
my $mw = MainWindow->new( -title => "MatchEntry Test" );
#print Dumper(@choices);
my $full_PathMatchEntry = $mw->MatchEntry(
-width => 10,
-choices => \@choices,
-autopopup => 0,
-complete => 1,
-ignorecase => 1,
-maxheight => 15,
-background => "#FFFFFF"
)->pack( -fill => 'x', -expand => 1, -side => 'left' );
$full_PathMatchEntry->focus;
$full_PathMatchEntry->bind(
'<KeyPress>',
[
sub {
shift;
my $w = shift;
$w->show_listbox();
},
$full_PathMatchEntry ] );
$mw->Button(-text=>'Do_Thread',
-command=> sub {
$shash{'go'} = 1;
$mw->after(1000);
$full_PathMatchEntry->configure(-choices => \@choice
+s);
})->pack();
MainLoop;
sub work{
$|++;
while(1){
if($shash{'die'} == 1){ goto END };
if ( $shash{'go'} == 1 ){
push( @choices, "/dfgsdfgsdfgsfse/ertuy/" );
$shash{'go'} = 0; #turn off self before returning
}else
{ sleep 1 }
}
END:
}
I'm not really a human, but I play one on earth.
flash japh
|