GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sat Oct 25, 2014 11:58 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: How to pack a widget inside a frame?
PostPosted: Thu Mar 05, 2009 6:03 pm 
Offline
Familiar Face

Joined: Tue Mar 03, 2009 6:03 pm
Posts: 15
I'm trying to pack a button inside a frame, but can't understand how to do this. I tried this and it compiles, but returns an error when executed:

Code:
   hbox = gtk_hbox_new (TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);

   frame = gtk_frame_new ("Some text");
   gtk_container_add (GTK_CONTAINER (hbox), frame);

   close_button = gtk_button_new_with_label ("Close");
   g_signal_connect_swapped (GTK_OBJECT (close_button), "clicked",
              G_CALLBACK (gtk_main_quit), GTK_OBJECT (box));
   gtk_box_pack_start (GTK_BOX (frame), close_button, TRUE, TRUE, 5);


Many thanks for any help in advance.
Rouslan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 6:29 pm 
Offline
GTK+ Geek

Joined: Thu Dec 20, 2007 5:24 pm
Posts: 56
Location: Turkey
You are trying gtk_box_pack_start() on frame and gtk_container_add() on hbox. I guess you mistyped the variables. The true code is:

Code:
   hbox = gtk_hbox_new (TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);

   frame = gtk_frame_new ("Some text");
   gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 5);

   close_button = gtk_button_new_with_label ("Close");
   g_signal_connect_swapped (GTK_OBJECT (close_button), "clicked",
              G_CALLBACK (gtk_main_quit), GTK_OBJECT (box));
   gtk_container_add (GTK_CONTAINER (frame), close_button);


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 05, 2009 6:55 pm 
Offline
Familiar Face

Joined: Tue Mar 03, 2009 6:03 pm
Posts: 15
DOH!

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 06, 2009 1:18 am 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
Note that you can still use gtk_container_add on a GtkBox derivative, it just calls gtk_box_pack_start with its default settings.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group