Thread: GTK+ packing widgets..

  1. #1
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058

    How do I pack GTK+ widgets nonuniformly?

    I'm using gtk_vbox_new and gtk_hbox_new to pack widgets on a window. My problem is that the packing is too uniform. Every widget is assigned the same uniform box size.

    In other words, this is what I want to accomplish. My first horizontal widget would be a text box, the next widget would be a listview and the third horizontal widget would again be a text box. Each widget would be of a different vertical and horizontal length. The text box would be one column horizontally and one row vertically , the listview would be two columns horizontally and four rows vertically and the next text box would be two columns horizontally and three rows vertically. How can I accomplish this nonuniform positioning?
    Last edited by BobS0327; 04-25-2006 at 07:18 PM.

  2. #2
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    Perhaps you'd like to use GtkTable in this case.
    Code:
    GtkWidget *table, *textbox1, *listview, *textbox2;
    
    table = gtk_table_new(5, 4, TRUE);
    gtk_table_set_col_spacings(GTK_TABLE(table), 6);
    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
    
    gtk_table_attach_defaults(GTK_TABLE(table), textbox1, 0, 1, 0, 1);
    gtk_table_attach_defaults(GTK_TABLE(table), listview, 1, 3, 0, 4);
    gtk_table_attach_defaults(GTK_TABLE(table), textbox2, 3, 5, 0, 3);

  3. #3
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    I had developed a mental block when I was reading the GTK documentation on packing. It was a little confusing. But your example made everything perfectly clear.

    THANX!!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 09-22-2008, 04:49 AM
  2. widgets in fedora7
    By munna_dude in forum Linux Programming
    Replies: 1
    Last Post: 10-24-2007, 01:41 AM
  3. GTK troubles...again...
    By cornholio in forum Linux Programming
    Replies: 4
    Last Post: 01-16-2006, 01:37 AM
  4. Gui: Qt vs. GTK vs. ?
    By pixsta in forum C++ Programming
    Replies: 3
    Last Post: 11-15-2005, 05:02 PM
  5. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM