Oops, sorry, I forgot to mention that the File Tk::AddScrollbars.pm is not existing, it seems to be autogenerated by widget.pm. If I add the line use Tk::AddScrollbars; or not doesn't matter. There only exists an AddScrollbars.al.
Ah, now I think I see the problem... par doesn't find the *.al-Files where the Method AddScrollbars is coded. If I add the code from several .al-Files (walk down the dependencies) to my script (see attachment), it's working great.


Thank you very much for pointing me in the right direction.

Best regards,

Martin Fabiani


At 18:28 24.02.2003 +0800, you wrote:
On Mon, Feb 24, 2003 at 11:21:53AM +0100, Martin Fabiani wrote:
> thank you for writing PAR which is a great tool. And until now, it worked
> great.

Thanks for your support. :-)

> I would like to pack the following code into an exe:
>
> #! /usr/bin/perl
> use warnings;
> use strict;
> use Tk;
>
> my $mw = MainWindow->new();
> $mw->Scrolled('Text')->pack;
>
> MainLoop;
<snip>
> F:\work\perl\partest>a.exe
> Can't locate Tk/AddScrollbars.pm in @INC (@INC contains: CODE(0xb11c58) E:/
> wampp
> 13a/perl/lib E:/wampp13a/perl/site/lib .) at /loader/0x13aaef4/Tk/Widget.pm
> line
>  259.

As the error message states, maybe you should add a:

use Tk::AddScrollbars;

in your script, as Module::ScanDeps cannot know which Tk widget(s) the script
is using.

A thought is to do a lexical analysis on all widget-looking statements:

/->(\w+)(.*)->pack/

on the source file, but I'm not sure how portable or accurate that
approach would be.  Comments welcome. :-)

Thanks,
/Autrijus/

Software Engineerung und Perl-Programmierung
Martin Fabiani
mailto:[EMAIL PROTECTED] / mailto:[EMAIL PROTECTED] / mailto:[EMAIL PROTECTED]
http://www.fabiani.net/ / http://www.linux-services.org/
tel: +49-69-47885599
fax: +49-69-49086465
#! /usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Scrollbar; # changed

my $mw = MainWindow->new();
$mw->Scrolled('Text')->pack;

MainLoop;

# copied from AddScrollbars.al
package Tk::Frame;
sub AddScrollbars
{
# require Tk::Scrollbar; # changed


    my ($cw,$w) = @_;
    my $def = '';
    my ($x,$y) = ('','');
    my $s = 0;
    my $c;
    $cw->freeze_on_map;
    foreach $c ($w->configure)
    {
        my $opt = $c->[0];
        if ($opt eq '-yscrollcommand')
        {
            my $slice  = Tk::Frame->new($cw,Name => 'ysbslice');
            my $ysb    = Tk::Scrollbar->new($slice,-orient => 'vertical', -command => 
[ 'yview', $w ]);
            my $size   = $ysb->cget('-width');
            my $corner = Tk::Frame->new($slice,Name=>'corner','-relief' => 'raised',
                                        '-width' => $size, '-height' => $size);
            $ysb->pack(-side => 'left', -fill => 'y');
            $cw->Advertise('yscrollbar' => $ysb);
            $cw->Advertise('corner' => $corner);
            $cw->Advertise('ysbslice' => $slice);
            $corner->{'before'} = $ysb->PathName;
            $slice->{'before'} = $w->PathName;
            $y = 'w';
            $s = 1;
        }
        elsif ($opt eq '-xscrollcommand')
        {
            my $xsb = Tk::Scrollbar->new($cw,-orient => 'horizontal', -command => [ 
'xview', $w ]);
            $cw->Advertise('xscrollbar' => $xsb);
            $xsb->{'before'} = $w->PathName;
            $x = 's';
            $s = 1;
        }
    }
    if ($s)
    {
        $cw->Advertise('scrolled' => $w);
        $cw->ConfigSpecs('-scrollbars' => ['METHOD','scrollbars','Scrollbars',$x.$y]);
    }
}

# end of Tk::Frame::AddScrollbars

# copied from freeze_on_map.al
sub freeze_on_map
{
    my ($w) = @_;
    unless ($w->Tk::bind('Freeze','<Map>'))
    {
        $w->Tk::bind('Freeze','<Map>',['packPropagate' => 0])
        }
    $w->AddBindTag('Freeze');
}

# end of Tk::Frame::freeze_on_map

# copied from scrollbars.al
sub scrollbars
{
    my ($cw,$opt) = @_;
    my $var = \$cw->{'-scrollbars'};
    if (@_ > 1)
    {
        my $old = $$var;
        if (!defined $old || $old ne $opt)
        {
            $$var = $opt;
            $cw->queuePack;
        }
    }
    return $$var;
}

# end of Tk::Frame::scrollbars

# copied from queuePack.al
#line 194 "blib\lib\Tk\Frame.pm (autosplit into blib\lib\auto\Tk\Frame\queuePack.al)"
sub queuePack
{
    my ($cw) = @_;
    unless ($cw->{'pack_pending'})
    {
        $cw->{'pack_pending'} = 1;
        $cw->afterIdle([$cw,'packscrollbars']);
    }
}

# end of Tk::Frame::queuePack

# copied from packscrollbars.al
#line 265 "blib\lib\Tk\Frame.pm (autosplit into 
blib\lib\auto\Tk\Frame\packscrollbars.al)"
sub packscrollbars
{
    my ($cw) = @_;
    my $opt    = $cw->cget('-scrollbars');
    my $slice  = $cw->Subwidget('ysbslice');
    my $xsb    = $cw->Subwidget('xscrollbar');
    my $corner = $cw->Subwidget('corner');
    my $w      = $cw->Subwidget('scrolled');
    my $xside  = (($opt =~ /n/) ? 'top' : 'bottom');
    my $havex  = 0;
    my $havey  = 0;
    $opt =~ s/r//;
    $cw->{'pack_pending'} = 0;
    if (defined $slice)
    {
        my $reqy;
        my $ysb    = $cw->Subwidget('yscrollbar');
        if ($opt =~ /(o)?[we]/ && (($reqy = !defined($1)) || $ysb->Needed))
        {
            my $yside = (($opt =~ /w/) ? 'left' : 'right');
            $slice->pack(-side => $yside, -fill => 'y',-before => $slice->{'before'});
            $havey = 1;
            if ($reqy)
            {
                $w->configure(-yscrollcommand => ['set', $ysb]);
            }
            else
            {
                $w->configure(-yscrollcommand => ['sbset', $cw, $ysb, 
\$cw->{'packysb'}]);
            }
        }
        else
        {
            $w->configure(-yscrollcommand => undef) unless $opt =~ s/[we]//;
            $slice->packForget;
        }
        $cw->{'packysb'} = $havey;
    }
    if (defined $xsb)
    {
        my $reqx;
        if ($opt =~ /(o)?[ns]/ && (($reqx = !defined($1)) || $xsb->Needed))
        {
            $xsb->pack(-side => $xside, -fill => 'x',-before => $xsb->{'before'});
            $havex = 1;
            if ($reqx)
            {
                $w->configure(-xscrollcommand => ['set', $xsb]);
            }
            else
            {
                $w->configure(-xscrollcommand => ['sbset', $cw, $xsb, 
\$cw->{'packxsb'}]);
            }
        }
        else
        {
            $w->configure(-xscrollcommand => undef) unless $opt =~ s/[ns]//;
            $xsb->packForget;
        }
        $cw->{'packxsb'} = $havex;
    }
    if (defined $corner)
    {
        if ($havex && $havey && defined $corner->{'before'})
        {
            my $anchor = $opt;
            $anchor =~ s/o//g;
            $corner->configure(-height => $xsb->ReqHeight);
            $corner->pack(-before => $corner->{'before'}, -side => $xside,
                          -anchor => $anchor, -fill => 'x');
        }
        else
        {
            $corner->packForget;
        }
    }
}

# end of Tk::Frame::packscrollbars

Reply via email to