Octavian Rasnita wrote:
Hi,
Please tell me how can I access the properties of the Wx::App object in the
subroutine which initializes that object.
Is it absolutely necessary to use global variables? (Because I couldn't find
another solution.)
I did:
use MyApp;
my $app = MyApp->new;
$app->{the_property} = "foo";
$app->MainLoop;
package MyApp;
use base 'Wx::App';
use Wx;
sub OnInit {
my $self = shift;
#Here I want to access the Wx::App object property "the_property"
#for sending it to the frames created with Wx::Frame
}
The OnInit method is called during ->new, so you can't set the
attribute after new and read it in OnInit. You could avoid OnInit
entirely by deriving MyApp from Wx::SimpleApp:
use MyApp;
my $app = MyApp->new;
$app->{the_property} = "foo";
# create the frame instance(s) here
$app->MainLoop;
package MyApp;
use base 'Wx::App';
use Wx;
# other overridden methods here.
HTH,
Mattia