Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hello Monks,

Perl: Strawberry Perl 5.18 (*on Windows XP)

A few months ago I wrote a very large GUI program using Perl Gtk2 which still seems to be working just fine. But I'm now
creating a MUCH smaller GUI script that I really just want to display a Popup window to ask the User Yes Or No. If they select
"No" then the script SHOULD exit. I don't remember ever having this issue in my last GUI program, but it was a while ago now and
I'm pretty confused by this error, and why the script won't exit.

Here is my Gtk2 code. At first I just created a MessageDialog object with 'undef' as its parent but I was getting errors. The error
wasn't specifically towards the parent window, but I decided to create a $window object (*toplevel) anyway and I just don't ever
issue the "->show_all" function to display it...
#!/usr/bin/perl use strict; use warnings; use Gtk2 -init; use Glib qw/TRUE FALSE/; my $window = Gtk2::Window->new('toplevel'); $window->signal_connect(destroy => sub {Gtk2->main_quit;}); #<---ERROR ### $window->show_all; my $msg_dialog = Gtk2::MessageDialog->new_with_markup($window, 'modal' +, 'error', 'yes-no', "Would you like to retry the connection?"); $msg_dialog->set_title("No Connection Found"); $msg_dialog->set_destroy_with_parent(TRUE); $msg_dialog->signal_connect (response => sub { my ($self, $response) = @_; if ($response eq 'yes') { $msg_dialog->hide(); my_function("yes"); } elsif ($response eq 'no') { $msg_dialog->destroy(); $window->destroy; } }); $msg_dialog->run(); Gtk2->main; 0;

So when I execute the script, the MessageDialog opens just fine and I click the "No" button and I get the following error:

Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed at C:\Documents and Settings\Administrator\My Documents \test_gtk.pl line 10.

Also, when the error gets displayed in the console window, the script basically just hangs until I do a Ctrl-C...

Anyone have any idea why this isn't working, am I missing something here?
Any thoughts or suggestions would be much appreciated, I'm not sure what else to try.

Thanks in Advance,
Matt

In reply to Perl Gtk2 - ->destroy() is Not Causing the Script to Exit by mmartin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-26 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found