/**
* 设置标签前景色和背景色的另一种方法
* 本例采用标记语言设置显示文本的前景色和背景色
* gcc -o 005.exe 005.c `pkg-config --cflags --libs gtk+-2.0`
*/
#include
int main(int argc,char** argv)
{
gtk_init(&argc,&argv);
GtkWidget* main_win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width(GTK_CONTAINER(main_win),5);
//创建label
GtkWidget* b = gtk_label_new(NULL);
//创建markup文本,并将其设置为label的文本内容
gchar* markup = g_markup_printf_escaped("Hello GTK");
gtk_label_set_markup(GTK_LABEL(b),markup);
gtk_container_add(GTK_CONTAINER(main_win),b);
g_signal_connect_swapped(
G_OBJECT(main_win),"destroy",
G_CALLBACK(gtk_main_quit),NULL);
gtk_widget_show_all(main_win);
gtk_main();
return 0;
}
阅读(1973) | 评论(0) | 转发(0) |