I'm trying to figure out how to get a directory or text entry in Perl/Tk. I
am very new to this, but I can't figure out why this won't work. It works
maybe 1 time out of 10. The rest of the time I get this error:
Tk::Error: grab failed: window not viewable at
/usr/lib/perl5/site_perl/5.8.0/Tk/FileDialog.pm line 986.
Tk callback for grab
Tk::FileDialog::RescanFiles at
/usr/lib/perl5/site_perl/5.8.0/Tk/FileDialog.pm line 986
Tk::FileDialog::Show at /usr/lib/perl5/site_perl/5.8.0/Tk/FileDialog.pm
line 654
main::get_dir at ./barfoo line XXXX
main::__ANON__ at ./barfoo line XXXX
Here is my poor code:
#!/usr/bin/perl -w
use strict;
use English;
use Tk;
use Tk::FileDialog;
my $main = MainWindow->new();
$main->title(" CardToDir");
$main->minsize( qw(250 250));
my $input_fr = $main->Frame()->pack(side => 'top');
my $src_fr = $input_fr->Frame()->pack(-side => 'top', -fill => 'x');
my $src_lbl = $src_fr->Label(-text => 'Enter Source Directory',
)->pack(-side => 'left');
my $src_file = $src_fr->Button(-text => '...',
)->pack(-side => 'right',
-fill => 'x');
my $src_entry = $src_fr->Entry(-width => 40
)->pack(-side => 'right');
$src_entry->insert('end' => '/home/user');
$src_file->bind('<1>' =>
sub {
get_dir($src_entry); # Called here
} );
$main->Button(-text => 'Quit',
-command => sub{exit}
)->pack(-side => 'bottom');
MainLoop();
sub get_dir {
my $file = shift;
my $selection ;
my $DirDialog = $input_fr->FileDialog(-Title => 'Titlexxx',
-Path => $file->get );
$selection = $DirDialog->Show(); # Error Here
$file->delete(0,'end');
$file->insert('end' => $selection);
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]