This code works fine for me on Slackware linux. Maybe since it only affects certain variants of OS, it's permissions releated? ( you are jumping up out of your homedir). Also checjk the buglist and try the latest version of Tk ...... Tk-804.028 which has fixed many bugs.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my $defaultdir = '/home'; #defaults to current dir
my $mw = MainWindow->new( -title => "Test DirSelect" );
my $selbut = $mw->Button(
-text => 'Select',
-command => [ \&dirsel, $defaultdir ]
)->pack();
my $quitbut = $mw->Button(
-text => 'Exit',
-command => sub { exit }
)->pack();
MainLoop;
#################################################
sub dirsel {
my $defaultdir = shift;
my $dir = $mw->chooseDirectory( -initialdir => $defaultdir );
print "$dir\n";
}
__END__
|