[英]GtkWidget, change background color
Sorry, I'm newbie in the Gtk, so it is may be the stupid question.抱歉,我是 Gtk 的新手,所以这可能是个愚蠢的问题。 I use Gtk+ 3.0 and have this code我使用 Gtk+ 3.0 并有这个代码
GtkWidget *widget;
widget=gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start(GTK_BOX(widget), some_label, FALSE, FALSE, 0);
How can I change the background color of the widget?如何更改小部件的背景颜色? I'm trying that我正在尝试
GdkColor red = {0, 0xffff, 0x0000, 0x0000};
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &red);
and some other examples, but no one of them worked for my case.和其他一些例子,但没有一个适用于我的情况。
在 GTK+ 3.0 中,您可以使用gtk_widget_override_background_color
。
In GTK+3 3.22 this markup code inside the text works.在 GTK+3 3.22 中,文本中的此标记代码有效。
gchar *text = "<b><span font='20' background='#ffffff' foreground='#404040'>I'm a colored label</span></b>";
gtk_label_set_text(GTK_LABEL(label), text);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.