and here is a Gtk2 example which demonstrates the difference between delete and destroy. The delete_event is what is connected to the window manager's Close button. It sounds like you may need to intercept one of those signals in Wx.> my $window => Gtk2::Window -> new; > $window -> signal_connect ( 'delete_event', sub { Gtk2 -> main_quit; + } ); Connect this to 'destroy' instead of 'delete-event'. The handler for 'delete-event' is supposed to return a boolean value saying "i handled + this" or "i didn't handle this", that is typically used to inhibit destructi +on of the window. You're not doing that, though. The default action from 'delete-event' is to destroy the window, which will cause the 'destroy +' event to fire. Of course, you can also get 'destroy' from other places in y +our program. So, if you connect the quit of the main loop to the main win +dow's 'destroy' rather than 'delete-event', you get a more robust program.
#!/usr/bin/perl use warnings; use strict; use Gtk2 -init; my $window = Gtk2::Window->new; $window->add( Gtk2::Label->new("I'm a banana!") ); $window->show_all; $window->signal_connect( delete_event => sub { return !ask( $_[0], "Really quit?" ); } ); $window->signal_connect( destroy => sub { Gtk2->main_quit } ); Gtk2->main; sub ask { my ( $parent, $question ) = @_; my $msgbox = Gtk2::MessageDialog->new( $parent, [], 'question', 'yes-no', $qu +estion ); my $response = $msgbox->run(); $msgbox->destroy; return $response eq 'yes'; }
In reply to Re: wxPreviewFrame error on closing
by zentara
in thread wxPreviewFrame error on closing
by Steve_BZ
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |