Newbie with probs Help!
- From: "Nicolas Raitman" <new_world radar com ar>
- To: "gtk app" <gtk-app-devel-list gnome org>
- Subject: Newbie with probs Help!
- Date: Sun, 19 Nov 2000 12:02:51 -0300
Hi to all... for you who do not remember I was having some problems in
passing arguments to callback functions. I will state the problem clearer
than before. Suppose that I have a label which will display the contents of
an entry when a button is clicked, simple isn't it? Well... I have done the
following, please look at the comments...
Thanks a lot, really and please HELP!
Nicolas
#include <gtk/gtk.h>
gint destroy (void)
{
gtk_main_quit();
return(FALSE);
}
void showname (GtkButton * button, GtkWidget * label)
{
/* Here I have the problem. How can I acces the label and the textbox at
the same time?? */
gtk_label_set_text(GTK_LABEL(label), /* I should put here the contents
of the entry, how can I do that? I mean, I have access to the label, but not
to the text... */ );
gtk_widget_show(label);
return;
}
int main (int argc, char * argv [])
{
GtkWidget * window;
GtkWidget * table;
GtkWidget * button;
GtkWidget * label;
GtkWidget * entry;
GtkWidget * nombre;
GtkWidget * box;
gtk_init(&argc, &argv);
/* Creacion de la Ventana Principal */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW (window), "X-ProMat");
gtk_container_border_width(GTK_CONTAINER (window), 25);
gtk_signal_connect (GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC
(destroy), NULL);
table = gtk_table_new (3, 3, FALSE);
label = gtk_label_new("Nombre:");
entry = gtk_entry_new();
button = gtk_button_new_with_label("Ingresar");
nombre = gtk_label_new("");
box = gtk_hbox_new(TRUE, 5);
gtk_signal_connect (GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC
(showname), nombre);
gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 10);
gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 10);
gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 10);
gtk_widget_show(label);
gtk_widget_show(entry);
gtk_widget_show(button);
gtk_table_attach(GTK_TABLE(table), box, 0, 2, 0, 1, GTK_FILL, GTK_FILL,
5, 5);
gtk_widget_show(box);
box = gtk_hbox_new(TRUE, 10);
gtk_box_pack_start(GTK_BOX(box), nombre, TRUE, TRUE, 10);
gtk_widget_show(nombre);
gtk_table_attach(GTK_TABLE(table), box, 0, 2, 1, 2, GTK_FILL, GTK_FILL,
5, 5);
gtk_widget_show(box);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_widget_show(table);
gtk_widget_show(window);
gtk_main();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]