第一个GTK+程序2010-09-15Linux programming约 114 字 预计阅读 1 分钟文章目录【注意】最后更新于 September 15, 2010,文中内容可能已过时,请谨慎使用。直接显示一个空白窗口,代码hello.c如下 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 /* compile command: gcc -o simple simple.c `pkg-config --libs --cflags gtk+-2.0` */ #include <gtk/gtk.h> int main( int argc, char *argv[]) { GtkWidget* window; GtkWidget* frame; GtkWidget* label; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Hello World"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); frame = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), frame); label = gtk_label_new("Hello World"); gtk_fixed_put(GTK_FIXED(frame), label, 10, 10); g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } 文章作者 Chen, Zai-Chun上次更新 2010-09-15许可协议 CC BY-NC-ND 4.0