Re: Access to a particular widget in a container...



lomba wrote:
> I've a main function create_window() which create a window and add the
> different containers. In the center of my window I have to add a container
> which contains a label and a text box. Since i've to do it two times, i
made
> a function (create_center()) which returns the container to
create_window().
> The problem is I have to modify the text in my textbox... But
> create_window() only see my container. Is there a solution (except global
> widgets) to access in create_window() to my textbox (created by
> create_center) ?

Hi Alexis, as a quick hack, you could pass create_center() the widget it 
is to build inside, and have it return the text box

     GtkWidget *
     create_center( GtkWidget *parent, const char *label_text )
     {
       GtkWidget *label, *text, *hbox;

       hbox = gtk_hbox_new(...
       gtk_container_add( GTK_CONTAINER( parent ), hbox );
       label = gtk_label_new( label_text );
       gtk_box_pack_start( GTK_BOX( hbox ), label ...
       text = gtk_entry_new(
       gtk_box_pack_start( GTK_BOX( hbox ), text ...

       return( text );
     }

a better solution is maybe to make your own widget (called LabelledText? 
something like that), it's pretty easy:

   http://www.gtk.org/tutorial/sec-creatingacompositewidget.html

John



========================================================== 

Madame de Pompadour 
Images of a Mistress 

16 October 2002 - 12 January 2003 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/pompadour/default.htm



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