Re: lookup_widget trouble



Op wo 01-01-2003, om 18:50 schreef Federico Vezzani:
Hello,
I'm new to GTK. At the moment I'm just trying to have a GTKButton that,
when clicked, sets a message text to a GTKEntry.

Here's my code in callbacks.c
<snip>
void
on_button1_clicked                    (GtkButton       *button,
                                        gpointer         user_data)
{
        GtkWidget *entry1;
        entry1 = lookup_widget(GTK_WIDGET(entry1), "entry1");

This should be:

entry1 = lookup_widget(GTK_WIDGET(widget), "entry1");

Where widget is the pointer to the toplevel widget of your dialog or
window. You can get it by calling

widget = gtk_widget_get_toplevel (GTK_WIDGET (button))

        gtk_entry_set_text(GTK_ENTRY(entry1), "abc");
}
</snip>

It compiles fine, but when I run it, the program crashes.
I'm sure there's something wrong with the lookup_widget method but I
can't understand what.


It crashes because you are trying to set an entry of a non-existing
widget.

Can anybody help me please?

Thank you
Fred



Hope this helps.

Regards,
Joop




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]