Solved

Can't locate object method "MainWindow"

Posted on 2007-03-25
15
253 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
Comment Utility
When I run that same code, it works.  Did the module install OK?  
0
 

Author Comment

by:tgoneil
Comment Utility
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
Comment Utility
HP_21.pm has this line:
use base qw/Tk::Calculator::RPN::HP/;

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

Author Comment

by:tgoneil
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:tgoneil
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
This video discusses moving either the default database or any database to a new volume.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now