最初,我学习了pyGtk。几个月后,我决定转到Gtkmm。阅读官方文档,它告诉我Gtk::Table已被弃用,我应该使用Gtk::Grid。
如果我想将小部件放在第2行和第3行之间,以及第4行和第5列之间,我可以将此代码与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);在阅读了Gtk::Grid之后,我尝试了同样的方法,但这次使用的是Gtk::Grid。
// 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);但当我尝试最后一段代码时,小部件(一个按钮)仍然放在左上角。有谁知道我哪里做错了吗?Gtk::Grid有能力做我想做的事情吗?
发布于 2016-11-02 12:41:59
该按钮保留在左上角,因为在第一行或前三列中没有其他小部件占用任何空间,因此它们折叠为零。
也许你想要的是
grid.set_row_homogeneous(true);
grid.set_column_homogeneous(true);然后在位置0,0和位置9,9附加空白小部件,以确保网格有10行10列。
https://stackoverflow.com/questions/39927988
复制相似问题