Search code examples
perlperltk

How to do map path to completion in Perl/Tk


The linux system in my server comes with Perl v5.14.1, and it seems like this version of Perl do not support Tk-PathEntry widget (pls refer to : https://code.activestate.com/ppm/Tk-PathEntry/). May I know is there any alternate way that I can do so that I can map path to completion in entry widgets for the sample script I get somewhere such as below?

#!/usr/bin/perl
use Tk;
use Tk::PathEntry;

use Cwd;

$path = cwd();

$mw = MainWindow->new();
$mw->geometry( '300x80' );
$mw->resizable( 0, 0 );

$mw->PathEntry( -textvariable=>\$path )->pack;
$mw->Label( -textvariable=>\$path, -foreground=>'blue' )->pack;
$mw->Button( -text=>'Quit', -command=>sub{ exit } )->pack;

MainLoop;

The error msg that I get as such, seem like the Perl version that I'm pointing to is not supporting the PathEntry widget:- Assuming 'require Tk::PathEntry;' at path.ptk line 14 Can't locate Tk/PathEntry.pm in @INC (@INC contains: /nfs/disks/my_work/scripts/Tk-PathEntry-2.23/lib /usr/pkgs/5.14.1/lib64/site_perl/x86_64-linux /usr/pkgs/perl/5.14.1/lib64/site_perl /usr/pkgs/perl/5.14.1/lib64/5.14.1/x86_64-linux /usr/pkgs/perl/5.14.1/lib64/5.14.1 /usr/pkgs/perl/5.14.1/lib64/module/default/x86_64-linux /usr/pkgs/perl/5.14.1/lib64/module/default .) at /usr/pkgs/perl/5.14.1/lib64/module/default/x86_64-linux/Tk/Widget.pm line 270

Pls advice. Thanks.


Solution

  • You could install this modul locally, without root rights and package with your script.

    You could use local::lib to make it easier but it may enough:

    perl Makefile.PL PREFIX=./modules
    make
    make install
    

    See details in this post to do it easier: How can I install a CPAN module into a local directory?