ddexter has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am having a problem using Tk::DirTree to let users select a directory path. Everything works well except when I try and open "/home". I can navigate around other directories like "/usr" and even "/home/(other folders)". It is only when I try to expand the "/home" directory that my program freezes. The problem happens on both the RHEL and Solaris computers that I have used to test this program. I can post some code if needed, but the way I initialize the DirTree object is exactly the same as the tutorial on the perltk.org website.

I was wondering if anyone else has had a similar problem or might know why this is happening. Thanks for your responses.

Replies are listed 'Best First'.
Re: Tk::DirTree freezes program
by Fletch (Bishop) on May 27, 2008 at 22:08 UTC

    Just an off the cuff guess, but without seeing any code (or knowing anything about the boxen in question) the first thing that comes to mind from the symptoms is that things under /home could be automounted and looking in the directory itself is causing a surge of mount requests.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Tk::DirTree freezes program
by zentara (Cardinal) on May 28, 2008 at 13:55 UTC
    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__

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      Hi Zentara, Thanks for the suggestion. Your code seems to work which leads me to believe that there is a bug in the newest DirTree package (I am using Tk-804.028 now). I will try to figure out what is causing it and submit a bug report. Until then, I think I will change my code to use chooseDirectory.