0%

GTK 创建最简单的一个创建窗口的示例

GTK 创建最简单的一个创建窗口的示例

程序代码:

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
34
35
36
37
38
39
40
41
#include <gtk/gtk.h>

//PROTOTYPES

void CloseRequest(GtkWidget *theWindow, gpointer data);

gint main(gint argc,gchar *argv[])

{

GtkWidget *window;

//get GTK+ to process the startup arguments

gtk_init(&argc,&argv);

//create the app’s main window

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

//connect a window’s signal to a signal function

gtk_signal_connect(GTK_OBJECT(window),“destroy”,GTK_SIGNAL_FUNC(CloseRequest),NULL);

gtk_widget_show(window);

gtk_main();

return 0;

}

//function to handle a close signal on the window

void CloseRequest(GtkWidget *theWindow,gpointer data)

{

gtk_main_quit();

}

程序编译:

1
gcc –Wall –o test main.c `pkg-config gtk+-2.0 –libs –cflags`
处无为之事,行不言之教;作而弗始,生而弗有,为而弗恃,功成不居!

欢迎关注我的其它发布渠道