Reputation: 11
I remember there was a formula in C to fill automatically a grid with buttons, and I can't find the page where I found it, can someone help me with that? I remember there were two FOR in use. Its is in GTK+ 3.0 and on C.
Upvotes: 1
Views: 1580
Reputation: 773
Like this:
// insert 9 buttons to a grid, 3x3.
void fill_grid_with_buttons(GtkWidget *grid)
{
GtkWidget *button;
int i, j;
for (i = 0; i < 3; i += 1) {
for (j = 0; j < 3; j += 1) {
button = gtk_button_new_with_label ("label");
gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
}
}
}
Upvotes: 1