Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Can't locate object method "MainWindow"

Posted on 2007-03-25
15
287 Views
Last Modified: 2010-03-05
While trying to exercise the Tk::Calculator::RPN::HP module, I get the following error message:

Can't locate object method "MainWindow" via package "Tk::Calculator::RPN::HP_21" at /usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN/HP.pm line 163.
 at /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/Tk/Widget.pm line 203

Here's the sample program:

#!/usr/bin/perl -w

use Tk;
use Tk::Calculator::RPN::HP;

my $mw = MainWindow->new;

$mw->Calculator( -type => "21")->pack;

MainLoop;
1;

Thank you.

0
Comment
Question by:tgoneil
  • 8
  • 7
15 Comments
 
LVL 39

Expert Comment

by:Adam314
ID: 18795306
When I run that same code, it works.  Did the module install OK?  
0
 

Author Comment

by:tgoneil
ID: 18795683
Hi Adam314,

Here's a synopsis of the install process in my SUSE 10.2 environment:

1)  The md5sum value for Tk-Calculator-RPN-HP-0.6.tar.gz matches the expected value:  c631a441c3c5bacc4e28cd88d5c00efd

2)  after extracting Tk-Calculator-RPN-HP-0.6.tar.gz, I did the usual:

perl Makefile.PL
make
make test
sudo make install

and, no fatal errors.

-----


Based on the error message about not finding MainWindow via the HP_21 module, I checked that:

Tk.pm contains:
require Tk::MainWindow;

and MainWindow.pm is present at one of the @INC paths:
/usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/Tk/MainWindow.pm

Is there an inheritance problem of some kind?

Any suggestions on how to continue resolving the issue?
Thank you for helping me with this problem.  I'm increasing point value to 200.
tgoneil




0
 
LVL 39

Assisted Solution

by:Adam314
Adam314 earned 250 total points
ID: 18796079
HP_21.pm has this line:
use base qw/Tk::Calculator::RPN::HP/;

is Tk::Calculator::RPM::HP in your @INC?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:tgoneil
ID: 18796431
In the test program, I went ahead and added the explicit path to @INC with:

push @INC, "/usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN";

at the start of the pl script.

It still generates the same error.  

Is there something else I can dump to help investigate?
=> increasing points to 250


0
 
LVL 39

Expert Comment

by:Adam314
ID: 18799528
Try putting this in HP.pm on line 163:
     print Dumper($self);   #After the bless $self, $calc;
And put this near the top:
    use Data::Dumper;
0
 

Author Comment

by:tgoneil
ID: 18799845
Here's what I get with the Dump.

Dumping $self just before "$calc->InitClass($self->MainWindow); ":

$VAR1 = bless( {
                 '_Destroy_' => [
                                  'ConfigSpecs'
                                ],
                 'TYPE' => '21',
                 '_TkValue_' => '.hp',
                 'ConfigSpecs' => {
                                    '-label' => [
                                                  'METHOD',
                                                  undef,
                                                  undef,
                                                  undef
                                                ],
                                    '-labelPack' => [
                                                      'METHOD',
                                                      undef,
                                                      undef,
                                                      undef
                                                    ],
                                    '-labelVariable' => [
                                                          'METHOD',
                                                          undef,
                                                          undef,
                                                          undef
                                                        ]
                                  }
               }, 'Tk::Calculator::RPN::HP_21' );
Can't locate object method "MainWindow" via package "Tk::Calculator::RPN::HP_21" at /usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN/HP.pm line 166.
 at /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/Tk/Widget.pm line 203
0
 
LVL 39

Expert Comment

by:Adam314
ID: 18800208
That is the same I get...
Is HP_21.pm in the same directory as HP.pm?
Is /usr/lib/perl5/site_perl/5.8.8/ the right include directory?
0
 

Author Comment

by:tgoneil
ID: 18800825
That is surprising!

HP_21.pm, HP.pm, and HP_16c.pm for that matter are all in the original directory after the install, namely:

/usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN

Shouldn't "MainWindow" be a component of $self?  

Thanks again for hanging in there with me.  I really appreciate it.
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 250 total points
ID: 18801247
MainWindow is inherited by $self.

If you put this in your sample program, does it work:
#!/usr/bin/perl;
use Tk;
use Tk::Calculator::RPN::HP_21;

0
 

Author Comment

by:tgoneil
ID: 18801681
When the line, "use Tk::Calculator::RPN::HP_21;" is added to the beginning of the sample program, it now gets the following compiler error:

Can't locate Tk/SlideSwitch.pm in @INC (@INC contains: /home/tgrego/Src/perl/PERLMODS /usr/lib/perl5/5.8.8/i586-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/site_perl/5.8.8/i586-linux-thread-multi/Tk/widgets.pm line 14.
 at /usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN/HP_21.pm line 5
BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.8.8/Tk/Calculator/RPN/HP_21.pm line 5.
Compilation failed in require at ./c21.pl line 9.
BEGIN failed--compilation aborted at ./c21.pl line 9.


0
 

Author Comment

by:tgoneil
ID: 18801709
I'm going out of town until Friday to Rosarito Beach, so will be out of touch for a while.  I'm going to give you 200 of the points for helping me this far.  
0
 

Author Comment

by:tgoneil
ID: 18801735
Just found out that the assigning partial points requires all points to be divided up, so gave you all 250 points over 2 of your entries.  Hope to talk with you to continue this when I get back.

Cheers!
tgoneil
0
 
LVL 39

Expert Comment

by:Adam314
ID: 18802230
You could have left the question open, that would have been okay.

It now appears that you don't have Tk::SlideSwitch installed, which is needed.  I don't know why this error didn't show up before.  Try installing that, then run your script again.
0
 

Author Comment

by:tgoneil
ID: 18829542
Hi Adam314,

It worked, finally!  The absence of Tk::SlideSwitch module was the ultimate culprit.  

The original error message complained about not being able to locate object method "MainWindow" via package "Tk::Calculator::RPN::HP_21" was entirely misleading about the fact that Tk::SlideSwitch had not yet been installed.  Hmmm...

Thanks for your patience with me on this issue.  Is there a way to change the annotation to indicate that your last comment about SlideSwitch was the real solution?

thanks again.
tgoneil


0
 
LVL 39

Expert Comment

by:Adam314
ID: 18836955
You can post a message in community support asking that the question be re-opened.  Then you can select the correct answer.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cpan issue 1 65
Perl Scripting from a shell script with if and for 4 87
Replace  text in a file 2 114
Regular Expression for URL 10 102
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question