Fwd: (fwd) Derived and ConfigSpecs
Steve Lidie <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Begin forwarded message:
>
>
> Hi all,
>
> I was under the impression that if you did something like:
>
> package Tk::Foo;
> use base qw/Tk::Derived Tk::Bar/;
>
> sub Populate {
> my ($self, $args) = @_;
> $self->ConfigSpecs(-blah => [qw/PASSIVE blah/]);
> $self->SUPER::Populate($args);
> }
>
> Then the new widget Foo would have all the configure options of
> Tk::Bar,
> plus the new -blah option for itself.
>
> Is this the case?
Yes.
>
> I'm trying to subclass Tk::Menubutton (I wrote about this recently)
> but
> it seems that Tk::Derived is not doing its job.
>
> Attached is my subclass package for Tk::MenuButton (notice the capital
> B). This derives from Tk::Menubutton. I've added the -command and
> -selectrelief options, and altered the -menu option with ConfigSpecs.
>
> However, if I run the following:
>
> use Tk;
> use Tk::MenuButton;
> $mw = tkinit;
> $mw->MenuButton(-tearoff => 0, # Menubutton opt
> -command => sub {print "OK!\n"}, # new opt
> -text => "TEST")->pack;
>
> I get the following error:
>
> Can't set -tearoff to `0' for Tk::MenuButton=HASH(0x8ef8548): unknown
> option "-tearoff" at
> /usr/local/lib/perl5/site_perl/5.8.7/mach/Tk/Configure.pm line 46 at
> /usr/local/lib/perl5/site_perl/5.8.7/mach/Tk/Derived.pm line 294
>
> What am I doing wrong? Is it because Tk::Menubutton does its
> configspecs
> in XS? If so, what can I do instead to make it work?
You want to subclass a Menu, not a Menubutton. XS is not the problem,
you just are using -tearoff with the wrong widget :) Generally
speaking, a Menubutton is never used these days, as the Menu widget
performs all its duties and more.
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server. If you wish to unsubscribe from this mailing list, send the
message body of "unsubscribe ptk" to [email protected]