Can't locate object method "MainWindow"

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.

tgoneilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Adam314Commented:
When I run that same code, it works.  Did the module install OK?  
0
tgoneilAuthor Commented:
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
Adam314Commented:
HP_21.pm has this line:
use base qw/Tk::Calculator::RPN::HP/;

is Tk::Calculator::RPM::HP in your @INC?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

tgoneilAuthor Commented:
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
Adam314Commented:
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
tgoneilAuthor Commented:
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
Adam314Commented:
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
tgoneilAuthor Commented:
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
Adam314Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tgoneilAuthor Commented:
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
tgoneilAuthor Commented:
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
tgoneilAuthor Commented:
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
Adam314Commented:
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
tgoneilAuthor Commented:
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
Adam314Commented:
You can post a message in community support asking that the question be re-opened.  Then you can select the correct answer.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.