For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > December 2004 > Creating a derived widget that is a -container









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Creating a derived widget that is a -container
H. Wade Minter

2004-12-07, 4:10 am

I'm creating a widget that is based on Tk::Frame. I want this widget
to be a container so that another toplevel can -use it for embedding.

The trick is that I want the -container flag to get set on this widget
DURING its construction. I'm pretty as to how to do this.

Should this be done during the ClassInit sub, or the Populate sub?

I'm trying it with Populate, but can't get it to work. I've got:

sub Populate {
my ($self, $args) = @_;
$self->SUPER::Populate($args);
$self->configure(-container=>1);
....
}

However, during the Populate, if I later try to -use $self's widget id,
I get:

Tk::Error: Can't set -container to `1' for Tk::MyWidget=HASH(0x8b3f00): can't
modify -container option after widget is created at /Library/Perl/5.8.1/
darwin-thread-multi-2level/Tk/Configure.pm line 46.

If I try to do something like:

sub Populate {
my ($self, $args) = @_;
$args->{-configure} = 1;
$self->SUPER::Populate($args);
$self->configure(-container=>1);
....
}

Then it just seems to silently fail like:

window ".foo" doesn't have -container option set at /Library/Perl/5.8.1/
darwin-thread-multi-2level/Tk/Widget.pm line 190.

Any suggestions as to what magic I need to do to enable this will be welcomed.

Thanks,
Wade
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com