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

Folks, OS : MAC 10.6 perl version : 5.10.0 I have been using the Tk::getOpenFile successfully for the past years. Now for some reason I cannot select a file in the getOpenFile window. I can navigate the directories in this window. The problem also existed with OS : MAC 10.5.8 perl version : 5.8.8 I have deleted the Tk installation and re-installed with no joy. Any suggestions?

Replies are listed 'Best First'.
Re: Tk::getOpenFile & select error
by jcook4615 (Initiate) on Sep 06, 2009 at 00:03 UTC

    Error message when the file is selected

    Tk::Error: Failed to AUTOLOAD 'Tk::FBox::_get_select_Path' at lucca_v1.pl line 186

    Carp::croak at /System/Library/Perl/5.10.0/Carp.pm line 44

    Tk::Widget::__ANON__ at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/Widget.pm line 347

    Tk::FBox::Done at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/FBox.pm line 909

    Tk::FBox::VerifyFileName at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/FBox.pm line 678

    Tk::FBox::ActivateEnt at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/FBox.pm line 647

    Tk::FBox::OkCmd at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/FBox.pm line 815

    Tk callback for .fbox.frame1.button

    Tk::__ANON__ at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk.pm line 250

    Tk::Button::butUp at /Library/Perl/5.10.0/darwin-thread-multi-2level/Tk/Button.pm line 175

    <ButtonRelease-1> (command bound to event)

Re: Tk::getOpenFile & select error
by lamprecht (Friar) on Sep 06, 2009 at 09:44 UTC

    There is a typo in Tk::FBox.pm. In line 909 _get_select_Path should be all lowercased. If you avoid the -multiple option, this should not show up.

    --- C:\strawberry-perl\perl\site\lib\Tk\FBox.pm Sa Feb 10 11:29:00 +2007 +++ C:\strawberry-perl\perl\site\lib\Tk\FBox-new.pm So Sep 6 11:39 +:02 2009 @@ -906,7 +906,7 @@ if ($w->cget('-multiple')) { $selectFilePath = []; for my $f (@{ $w->{'selectFile'} }) { - push @$selectFilePath, JoinFile($w->_get_select_Path, $f); + push @$selectFilePath, JoinFile($w->_get_select_path, $f); } } else { $selectFilePath = JoinFile($w->_get_select_path,

    Cheers, Christoph

      Just checked: This has been fixed in Tk-804.028_501 already.


      Cheers, Christoph
      Chris,

      Thanks for the response regarding _get_select_path.

      After fixing the above mentioned, I was able to modify FBox.pm to solve my initial problem.

      I found that if the multiple option was selected, a file name was returned.

      So I modified the routine 'ActivateEnt'as follows

      sub ActivateEnt {

      my $w = shift;

      if ($w->cget(-multiple)) {

      # For the multiple case we have to be careful to get the file

      # names as a true list, watching out for a single file with a

      # space in the name. Thus we query the IconList directly.

      $w->{'selectFile'} = [];

      for my $item ($w->{'icons'}->Curselection) {

      $w->VerifyFileName($w->_get_from_icons($item));

      }

      } else {

      #my $ent = $w->{'ent'};

      #my $text = $w->_encode_filename($ent->get);

      #print "text : $text\n";

      #$w->VerifyFileName($text);

      $w->{'selectFile'} = [];

      for my $item ($w->{'icons'}->Curselection) {

      $w->VerifyFileName($w->_get_from_icons($item));

      }

      }

      }

      Cheers Jonathan