Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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

by smh (Novice)
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/Widget.pm line 1214.

Any idea on how I can do this.

Regards, smh

Comment on How can I add a new option to a composit ptk widget
Select or Download Code
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

      "$self->SUPER::Populate($args)"

      then every thing works the same as all other args.

      Regards, smh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://964695]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2015-07-30 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls