Re: [gtk-list] Glade



JA wrote:
> 
> I'm using Glade and I'm making practics with it, but I can't use the
> gtk_entry_set_text to make a program in which, when you push a button the
> text from an entry change. If anybody can (I suppose almost everyone can)
> help me please do it.

You can't do this:
 
 gtk_entry_set_text (GTK_ENTRY (ven_principal->txt_formula),
                     "Hola Caracola");

Your ven_principal is just a normal GtkWindow widget - its struct does not
have a txt_formula field.

Glade stores pointers to all the widgets in a window or dialog inside the
toplevel widget (using gtk_object_set_data() with the widget name as the key).

Glade also provides a get_widget() function, which returns a pointer to a widget
given any other widget in the window/dialog and the name of the widget you want
to get. So you can do this:


void
on_btn_calcular_clicked                (GtkButton       *button,
                                        gpointer         user_data)
{
  GtkWidget *txt_formula;

  txt_formula = get_widget (GTK_WIDGET (button), "txt_formula");
  gtk_entry_set_text (GTK_ENTRY (txt_formula), "Hola Caracola");
}




Damon



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