Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Tcl::pTk Can't locate object method "findINC" via package "Tk"

by Anonymous Monk
on Jun 16, 2018 at 03:32 UTC ( [id://1216767]=perlquestion: print w/replies, xml ) Need Help??

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

I am experimenting with Tcl::pTk (0.92) on a macOS to have access to Tcl/Tk and avoid the old and ugly Perl/Tk. Why on earth does this module complains about a missing Tk object "Can't locate object method "findINC" via package "Tk"? Why should I have Perl/Tk if I want to avoid its use? This is not a secondary problem, as I do not want Tk because it requires my to install X11, which I do not want to have installed. Any idea?

  • Comment on Tcl::pTk Can't locate object method "findINC" via package "Tk"

Replies are listed 'Best First'.
Re: Tcl::pTk Can't locate object method "findINC" via package "Tk"
by chrstphrchvz (Scribe) on Feb 25, 2019 at 02:48 UTC

    Tcl::pTk maintainer here. I've finally gotten around to looking at a report for what I think is the same issue as the one here: RT #127529.

    The Tk->findINC statement was originally copied from Perl/Tk, but should have at least been changed to Tcl::pTk->findINC. Expect a fix for this in the next Tcl::pTk version, which I should have ready soon.

    Edit: I have uploaded Tcl::pTk 0.95, which should fix this issue.

Re: Tcl::pTk Can't locate object method "findINC" via package "Tk"
by Anonymous Monk on Jun 16, 2018 at 03:34 UTC

    The Tcl::pTk that requires the Tk object is

    # Tcl::pTk::libary variable: Translation from perl/tk Tk.pm {($Tcl::pTk::library) = __FILE__ =~ /^(.*)\.pm$/;} $Tcl::pTk::library = Tk->findINC('.') unless (defined($Tcl::pTk::libra +ry) && -d $Tcl::pTk::library);

    $Tcl::pTk::library don't know what it is.

Re: Tcl::pTk Can't locate object method "findINC" via package "Tk"
by Anonymous Monk on Jun 16, 2018 at 03:44 UTC

    In the Tcl::pTk module there is the following subroutine

    # subroutine findINC copied from perlTk/Tk.pm sub findINC { my $file = join('/',@_); # Normal location my $fileImage = join('/', $_[0], 'images', $_[1]); # alternate loc +ation in the 'images' directory my $dir; $file =~ s,::,/,g; $fileImage =~ s,::,/,g; foreach $dir (@INC) { my $path; # check for normal location and 'images' location of the file return $path if (-e ($path = "$dir/$file") ); return $path if (-e ($path = "$dir/$fileImage") ); } return undef; }

    So not weite sure about the object Tk->findINC

Re: Tcl::pTk Can't locate object method "findINC" via package "Tk"
by Anonymous Monk on Jun 16, 2018 at 09:06 UTC
    Never heard tcl::ptk complain about findinc. What code are you running?

      Code as simple as:

      use Tcl::pTk; my $mw = MainWindow->new(); my $lab = $mw->Label(-text => "Hello world")->pack; my $btn = $mw->Button(-text => "test", -command => sub { $lab->configure(-text=>"[". $lab->cget('-text')."]"); })->pack; MainLoop;

      I love the module Tcl::pTk as it gives me access to the GUI TclTk which on a macOS is great. And as far as I can tell, it works great too.

      For the moment I commented out in pTk.pm the line $Tcl::pTk::library = Tk->findINC('.') unless (defined($Tcl::pTk::library) && -d $Tcl::pTk::library); and it seems to work fine. BUT as I really do not know what this lines is there for AND I do not like the idea to modify the module, I do not feel very well about this solution.

        Hi,

        Thats weird, it works fine for me

        What happens if you add  use Tcl::pTk::TkHijack; ?

        Which versions do you have?

        #!/usr/bin/perl -- use strict; use warnings; use Tcl::pTk; my $int = new Tcl::pTk; $int->Eval(<<'EOS'); # pure-tcl code to create widgets (e.g. generated by some GUI builder) text .e ## http://wiki.tcl.tk/1626#tk_version .e insert end "tcl_version $tcl_version\n" .e insert end "tcl_patchLevel $tcl_patchLevel\n" .e insert end "tk_version $tk_version\n" .e insert end "tk_patchLevel $tk_patchLevel\n" .e insert end "tk_library $tk_library\n" pack .e EOS my $e = $int->widget('.e'); # get .e entry into play $e->insert( "end", " Tcl::pTk $Tcl::pTk::VERSION Tcl $Tcl::VERSION \$^V $^V \$] $] "); $int->MainLoop; my $mw = MainWindow->new(); my $lab = $mw->Label(-text => "Hello world")->pack; my $btn = $mw->Button(-text => "test", -command => sub { $lab->configure(-text=>"[". $lab->cget('-text')."]"); })->pack; MainLoop; __END__ tcl_version 8.6 tcl_patchLevel 8.6b1.2 tk_version 8.6 tk_patchLevel 8.6b1.2 tk_library C:/Tcl8.6/lib/tk8.6 Tcl::pTk 0.90 Tcl 1.02 $^V v5.16.1 $] 5.016001

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1216767]
Approved by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-25 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found