Hello Monks,

I have a Perl script using Gtk2 to create a UI for the user. In the snippet of code below I took from my script, I create
a MessageDialog then below that is the function that gets call when someone clicks my "submit" button in my main "parent"
window called "$window".

Now I create the MessageDialog outside the function so that I can use the same MessageDialog window for a number of different
situations so I don't have to keep creating new one's over and over...

So let's say the user entered the wrong data into an entry field in my parent window, then they click submit. So then my "submit_function()"
get called and in it I check the User's input, and if the input doesn't match my REGEX then I set the Text for the dialog, then run it.

#......... #:............ # Other code above here which creates the parent window which includes + a submit button... #:............ #......... # Create a Gtk2::MessageDialog to show Errors/Warnigns in: my $dialog_msgString = ""; my $msg_dialog = Gtk2::MessageDialog->new_with_markup($window, 'modal' +, 'warning', 'ok', $dialog_msgString); $msg_dialog->signal_connect (response => sub { my ($self, $response) = @_; if ($response eq 'ok') { print "*YOU CLICKED OK\n\n"; $msg_dialog->destroy(); } }); ### This will get Executed when the 'clicked' signal is caught for the + "$submit_button": sub submit_function() { my $endTime = $entry_field->get_text(); # If the endTime does NOT match the REGEX, then... if ($endTime !~ /^[0-9]{1,}$/i) { $msg_dialog->set_markup("<span size='11000'>Warning: The time +you entered is incorrect, numbers only!</span>"); $msg_dialog->run(); } } ### This will get Executed when the 'clicked' signal is # caught for the "$cancel_button": sub cancel_function() { print "\n\n\n${BOLD_RED}*YOU CLICKED THE 'CANCEL' BUTTON!!\n\t*EXI +TING NOW....${OFF}\n\n"; exit 101; } ### When control reaches here GTK will sleep and wait for X Events Gtk2->main; 0;


Ok, so I hope I didn't leave out anything important from the script, but above is basically what's needed to know the error I think...

So what happens is when I click the submit button and the user's input didn't match the REGEX, I set_markup() for the MessageDialog then
issue the "run()" method to show the dialog. This part works fine...
But then if I still entered the incorrect data into the $entry_field and click submit again, the parent window closes and the script exits
with the error below...

        Gtk-CRITICAL **: IA__gtk_label_set_markup: assertion `GTK_IS_LABEL (label)' failed at ./test_GUI line 586.

            *Line 586 is the line with "$msg_dialog->set_markup(.....);" in the submit_function() Function.

Anyone know why I would be getting this Error ONLY on the second time it gets executed and NOT on the first call of set_markup()??
Any thoughts would be much appreciated!

Thanks in Advance,
Matt



In reply to Gtk2::MessageDialog Getting Error while using "set_markup()" Method by mmartin

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.