How do I make a Gtk.Frame's label bold?
Usually, for Labels you can do something like this:
Label label = new Label ("<b>Some Text</b>") {
开发者_运维知识库UseMarkup = true
};
However, Gtk.Frame's label is just a string, not a full-fledged Label. I can't find an option to use markup. How to I enable markup, or otherwise set the label to be bold?
The label of a GtkFrame can be any widget and you can use your own GtkLabel if you wish.
Gtk.Frame has the possibility of setting any widget as "label". You can access this widget by accessing the property LabelWidget. Using this possibility, you can set a new Gtk.Label with any properties you need.
var frmExample = new Gtk.Frame();
frmExample.LabelWidget = new Gtk.Label() { Markup = "<b>Example</b>" };
this.Add( frmExample );
this.showAll();
The solution is actually simpler for the specific case of a label with markup. I've found that the Gtk.Frame already has a Gtk.Label attached, and, as you said, you can set the markup property to true.
var frmExample = new Gtk.Frame( "<b>Example</b>" );
( (Gtk.Label) this.frmExample.LabelWidget ).UseMarkup = true;
this.Add( frmExample );
this.showAll();
Hope this helps.
Not sure how it would look in C# but in plain C you could do this:
frame = GTK_WIDGET (g_object_new (GTK_TYPE_FRAME, "label", "", NULL));
label = gtk_label_new(_("<b>Scope</b>"));
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
gtk_frame_set_label_widget (GTK_FRAME(frame), label);
精彩评论