1

Originally I learned pyGtk. After a few months I decided to switch to Gtkmm. Reading the oficial documentation it tells that Gtk::Table is deprecated and I should use Gtk::Grid instead.
If I want to place the widget between the 2nd and 3rd row, and between the 4th and 5th column, I use this code with Gtk::Table.

// Create variable.        
Gtk::Table table;

//Initiate table.
table(10,10,true);

//Place the widget in the proper position.
// table.attach(widget, left_attach, right_attach, top_attach, bottom_attach);
table.attach(widget,4,5,2,3);

After reading about Gtk::Grid I tried the same thing, but using Gtk::Grid this time.

// Create variable.        
Gtk::Grid grid;

//Place the widget in the proper position.
//grid.attach(widget, left, top, higth, width); 
grid.attach(widget,4,2,1,1);

But when I try the last code the widget(a button), remains placed in the top left corner. Anyone have a clue about what I'm doing wrong? Does Gtk::Grid has the capacity to do what I want?

4

1 回答 1

1

该按钮保留在左上角,因为第一行或前三列中没有其他小部件占用任何空间,因此它们折叠为零。

可能你想要的是

grid.set_row_homogeneous(true);
grid.set_column_homogeneous(true);

然后在位置 0、0 和位置 9、9 处附加空白小部件,以确保网格有 10 行和 10 列。

于 2016-11-02T04:41:59.257 回答