Question about perl5 and tkpack() 
Author Message
 Question about perl5 and tkpack()

I'm trying to figure out how to get inheritance working so I can
create classes of "compound" widgets.  I'm having trouble and was
hoping someone could help me.

I've tried to create a class called "ScrollingListbox", which is a
Listbox with a Scrollbar.  I've defined the class in a file called
"ScrollingListbox.pm" which contiains:
--------------------------------------------------
package ScrollingListbox;

sub new {

        $listbox = Listbox::new($parent);
        $scrollbar = Scrollbar::new($parent);
        bless { Listbox => $listbox, Scrollbar => $scrollbar };

Quote:
}

--------------------------------------------------

In my main file called "test" I've got:
----------------------------------------------
#!/usr/local/bin/perl5 -w

use Tk;
use ScrollingListbox;

$top = tkinit;

$colors = ScrollingListbox::new($top);

tkpack($colors);

tkmainloop;
----------------------------------------------

When I run this script, I get an error at the "tkpack()" line:
--------------------------------------------------
fas% ./test
Subroutine Proxy::id redefined at
                 /usr/local/pkgs/perl5.000/lib/perl5/Tk.pm line 65535.
bad widget ref at ./test line 10.
fas%
--------------------------------------------------

I always get the "Subroutine Proxy::id..." warning when I use "-w" and
Tk, but I can't figure out what the problem is with the tkpack() call.

Thanks for any help you can give.

        - Tom



Tue, 29 Apr 1997 03:55:12 GMT  
 Question about perl5 and tkpack()

Thomas> I'm trying to figure out how to get inheritance working so I
Thomas> can create classes of "compound" widgets.  I'm having trouble
Thomas> and was hoping someone could help me.

Thomas> I've tried to create a class called "ScrollingListbox", which is a
Thomas> Listbox with a Scrollbar.  I've defined the class in a file called
Thomas> "ScrollingListbox.pm" which contiains:

Thomas> package ScrollingListbox;
Thomas> use Tk;

Thomas> sub new {

Thomas>      $listbox = Listbox::new($parent);
Thomas>      $scrollbar = Scrollbar::new($parent);
Thomas>      bless { Listbox => $listbox, Scrollbar => $scrollbar };
Thomas> }

You need to put the "use Tk;" before the package declaration, and then
you need to add "1;" to the end of ScrollingListbox.pm so that the
package returns a true value.

You can look at scrolledlistbox.pl which is part of the Tkperl5a5
distribution.

John


 Workstation Specialist - Worcester Polytechnic Institute College Computer Ctr.
                        Kill your television



Tue, 29 Apr 1997 08:17:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. tkpack (a packing wizard) available for download

2. tkpack - a packing program

3. dereference and xs question(perl5.000) (Solved)

4. dereference and xs question(perl5.000)

5. some questions about variable scope in perl5.000

6. Perl5 Regexp Question

7. perl5.000 dynamic loading problem/question

8. XWindows and Perl5 question

9. perl5 package/method invoc. question

10. newbie question about Perl5

11. Perl5 TIEARRAY question

12. perl5 local() question?

 

 
Powered by phpBB® Forum Software