Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

How can I add a new option to a composit ptk widget

by smh (Acolyte)
on Apr 12, 2012 at 04:40 UTC ( #964695=perlquestion: print w/replies, xml ) Need Help??
smh has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am making a new composit tk widget using tk::tree. I want to add pass an \@A to my new widget, the code is too long. I have used the following statement.

my $TREELEVEL = [ [2], [1,2,3], [5,6,7]]; $self->ConfigSpecs ( -treelevels => ['METHOD', qw/treelevels Treelev +els/, $TREELEVEL/ ], );

When I run my code I get the following error message:

bad option "-treelevels": must be -after, -anchor, -before, -expand, - +fill, -in, -ipadx, -ipady, -padx, -pady, or -side at C:/PRG/Perl/site/lib/Tk/ line 1214.

Any idea on how I can do this.

Regards, smh

Replies are listed 'Best First'.
Re: How can I add a new option to a composit ptk widget
by zentara (Archbishop) on Apr 12, 2012 at 11:13 UTC
    You only show a bit of code, but it seems you are running into an old problem with objects where you need to delete your new option first. Read perldoc Tk::Derived. For example:
    sub Populate { my ( $self, $args ) = @_; #------------------------------------------------------------------- #take care of args which don't belong to the SUPER, see Tk::Derived my $xtra_arg = delete $args->{-dooda}; #delete and read same time if( defined $xtra_arg ) { $self->{'dooda'} = $xtra_arg } #----------------------------------------------------------------- $self->SUPER::Populate($args); } Otherwise, show a complete running example.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      Thanks for the help. It worked. All I had to is to make sure, the args that were not in the widgets are defined before


      then every thing works the same as all other args.

      Regards, smh

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964695]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-04-22 09:52 GMT
Find Nodes?
    Voting Booth?