CtkBox versus CtkGrid: spacing

With CtkBox, you have to specify the “spacing” when you construct it. This property specifies the space that separates the children from each other. Additionally, you can specify extra space to put around each child individually, using the CtkBox padding child property.

CtkGrid is very similar when it comes to spacing between the children, except that it has two separate properties, “row-spacing” and “column-spacing”, for the space to leave between rows and columns. Note that row-spacing is the space between rows, not inside a row. So, if you doing a horizontal layout, you need to set “column-spacing”.

CtkGrid doesn't have any custom child properties to specify per-child padding; instead you can use the “margin” property. You can also set different padding on each side with the “margin-left”, “margin-right”, “margin-top” and “margin-bottom” properties.

Example 55. Spacing in boxes

         box = ctk_box_new (CTK_ORIENTATION_VERTICAL, 6);
         ctk_box_pack_start (CTK_BOX (box), child, FALSE, FALSE, 12);
      

This can be done with CtkGrid as follows:

         grid = ctk_grid_new ();
         ctk_grid_set_row_spacing (CTK_GRID (grid), 6);
         g_object_set (child, "margin", 12, NULL);
         ctk_grid_attach (CTK_GRID (box), child, 0, 0, 1, 1);