wx question

R

Robin

in the following program...

#!/usr/bin/perl

use Wx;
my $m = Wx::SimpleApp -> new;
my $f = Wx::Frame -> new (undef, -1, "hello world");
$f -> Show();
my $button = Wx::Button -> new ($f, -1, "Exit");

EVT_BUTTON ();
$m -> MainLoop ();


sub o () {
exit ();
}

--

why does perl give me the error undefined subroutine
&main::EVT_BUTTON called at line 9?

I am really stumped by this and looked on the web for answers but
could not find anything
Thanks.
yea.
-Robin
 
J

John Bokma

Robin said:
in the following program...

#!/usr/bin/perl

use Wx;
my $m = Wx::SimpleApp -> new;
my $f = Wx::Frame -> new (undef, -1, "hello world");
$f -> Show();
my $button = Wx::Button -> new ($f, -1, "Exit");

EVT_BUTTON ();
$m -> MainLoop ();


sub o () {
exit ();
}

You have to import EVT_BUTTON.

Add under

use Wx;

the following:

use Wx::Event qw( EVT_BUTTON );
 
R

Robin

John said:
You have to import EVT_BUTTON.

Add under

use Wx;

the following:

use Wx::Event qw( EVT_BUTTON );


--
John Bokma j3b

Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development

#!/usr/bin/perl

use Wx;
use Wx::Event qw( EVT_BUTTON );

my $m = Wx::SimpleApp -> new;
my $f = Wx::Frame -> new (undef, -1, "hello world");
$f -> Show();
my $button = Wx::Button -> new ($f, -1, "Exit");
EVT_BUTTON ($self, $button, \&o);
$m -> MainLoop ();

sub o {
exit;
}

this is what my code looks like now (above)-

it is now giving my the error:

can't call method connect on an undefined value at *event.pm...

do you know what this is?
 
J

John Bokma

Robin said:
#!/usr/bin/perl

use Wx;
use Wx::Event qw( EVT_BUTTON );

my $m = Wx::SimpleApp -> new;
my $f = Wx::Frame -> new (undef, -1, "hello world");
$f -> Show();
my $button = Wx::Button -> new ($f, -1, "Exit");
EVT_BUTTON ($self, $button, \&o);
$m -> MainLoop ();

sub o {
exit;
}

this is what my code looks like now (above)-

it is now giving my the error:

can't call method connect on an undefined value at *event.pm...

do you know what this is?

An incomplete error message ;-) Please copy and paste the actual
complete message.

Adding

use strict;
use warnings;

before use Wx; might help as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top