From: Zeke L. <ove...@ks...> - 2002-01-28 04:55:48
|
Could somebody point me in the right direction of making a dialog where if they click ok it goes ahead and closes the program but if they click cancel it goes back. I'm new to wxPerl I've tried copying some of the source from the dialogs sample but it doesn't work, this is what I got: sub OnQuit { my( $this, $event ) = @_; my $dialog = Wx::MessageBox( 'Exiting Worms GUI!', 'Message', wxOK|wxCANCEL, $this); if( $dialog->ShowModal == wxID_CANCEL ) { $dialog->Destroy; } else { $this->Close( 1 ); } } When I click either Ok or Cancel, I get this error: Can't call method "ShowModal" without a package or object reference at test3.pl line 72. and then perl crashes. Any help would be appreciated. |
From: Michele B. <mb...@it...> - 2002-01-28 11:26:41
|
Hi! > my $dialog = Wx::MessageBox( 'Exiting Worms GUI!', 'Message', > wxOK|wxCANCEL, $this); I would try I a wxMessageDialog: my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', wxOK | wxCANCEL, wxDefaultPosition); The ShowModal() you called should work fine then. Be sure to import the constants, prepending something like: use Wx qw(wxOK wxCANCEL wxDefaultPosition); or: use Wx qw(:everything) Michele. -- Michele Beltrame http://www.italpro.net/mb/ ICQ# 76660101 - e-mail: mb...@it... |
From: Zeke L. <ove...@ks...> - 2002-01-28 21:28:14
|
>I would try I a wxMessageDialog: >my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', > wxOK | wxCANCEL, wxDefaultPosition); >The ShowModal() you called should work fine then. Ok, I did that but I get errors, here's my code: # these are some constants used by Wx::MessageBox use Wx qw(:everything); # called when the user selects the 'Exit' menu item sub OnQuit { my( $this, $event ) = @_; my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', wxOK | wxCANCEL, wxDefaultPosition); if( $dialog->ShowModal == wxID_CANCEL ) { $dialog->Destroy; } else { $this->Close( 1 ); } } and then Perl Crashes, and I get this message in the console: Error while autoloading 'Wx::MessageDialog' at test3.pl line 71 Line 71 is the my $dialog line. All help so far is appreciated greatly. |
From: Michele B. <mb...@it...> - 2002-01-29 00:08:19
|
Hi! > Ok, I did that but I get errors, here's my code: If this is ALL your code, you miss some things. Can you post (or send me) the full source program you have, so I can better understand? Thank you, Michele. -- Michele Beltrame http://www.italpro.net/mb/ ICQ# 76660101 - e-mail: mb...@it... |
From: Michele B. <mb...@io...> - 2002-01-29 11:51:44
|
Hi! > my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', wxOK > | wxCANCEL, wxDefaultPosition); > [...] > and then Perl Crashes, and I get this message in the console: > Error while autoloading 'Wx::MessageDialog' at test3.pl line 71 Er, I made a mistake. The Dialog should (of course) be initialized calling the constructor, so that's actually: my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', wxOK | wxCANCEL, wxDefaultPosition); ...and then ShowModal() should be called. I tried myself the code and, oddly enough, it only works under MSl Windoze. If I use Linux, the program exits with a segmentation fault when ShowModal() is called. The reported error is: ----- Can't locate object method "ShowModal" via package "Wx::GenericMessageDialog" (perhaps you forgot to load "Wx::GenericMessageDialog"?) ----- Michele. -- Michele Beltrame http://www.italpro.net/mb/ ICQ# 76660101 - e-mail: mb...@it... |
From: Mattia B. <mb...@ds...> - 2002-01-29 19:54:48
|
> Hi! > > > my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', wxOK > > | wxCANCEL, wxDefaultPosition); > > [...] > > and then Perl Crashes, and I get this message in the console: > > Error while autoloading 'Wx::MessageDialog' at test3.pl line 71 > > Er, I made a mistake. The Dialog should (of course) be initialized calling > the constructor, so that's actually: > > my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', > wxOK | wxCANCEL, wxDefaultPosition); my $dialog = Wx::MessageDialog->new( .... ); ^^^^^ > ...and then ShowModal() should be called. > > I tried myself the code and, oddly enough, it only works under MSl Windoze. I'm really surprised it works at all... > If I use Linux, the program exits with a segmentation fault when ShowModal() > is called. The reported error is: > > ----- > Can't locate object method "ShowModal" via package "Wx::GenericMessageDialog" > (perhaps you forgot to load "Wx::GenericMessageDialog"?) > ----- Regards Mattia |
From: Michele B. <mb...@io...> - 2002-01-29 23:00:23
|
Hello! > > my $dialog = Wx::MessageDialog($this, 'message', 'Exiting Worms GUI', > > wxOK | wxCANCEL, wxDefaultPosition); > my $dialog = Wx::MessageDialog->new( .... ); > ^^^^^ Er, of course, I actually wrote the previous email to correct THAT, but then I just did a cut&paste of the previous code forgetting to add the "->new". :-( > > I tried myself the code and, oddly enough, it only works under MSl Windoze. > I'm really surprised it works at all... Ok, with the proper syntax it only works under Windows and still dies with a segmentation fault (error described in previous email) under GNU/Linux. Quite odd. Michele. -- Michele Beltrame http://www.italpro.net/mb/ ICQ# 76660101 - e-mail: mb...@it... |