GTK 编程:小部件打包与按钮使用全解析
1. 小部件打包基础
在 GTK 编程中,小部件的打包是构建界面的关键步骤。以下代码展示了如何将小部件打包到垂直框(vbox)中,并将其添加到主窗口:
/* pack the quitbox into the vbox (box1) */
gtk_box_pack_start (GTK_BOX (box1), quitbox, FALSE, FALSE, 0);
/* Pack the vbox (box1) which now contains all our widgets, into the
* main window. */
gtk_container_add (GTK_CONTAINER (window), box1);
/* And show everything left */
gtk_widget_show (button);
gtk_widget_show (quitbox);
gtk_widget_show (box1);
/* Showing the window last so everything pops up at once. */
gtk_widget_show (window);
/* And of course, our main function. */
gtk_main ();
/* Control returns here when gtk_main_quit() is called, but not when
* gtk_exit is used. */
return(0);
上述代码的操作步骤如下:
1. 使用 <
超级会员免费看
订阅专栏 解锁全文
1

被折叠的 条评论
为什么被折叠?



