Line wrapping in GtkCheckButton or GtkRadioButton labels

▼魔方 西西 提交于 2020-01-07 04:59:05

问题


Is there any way to get the label of a GtkCheckButton or GtkRadioButton to wrap when its parent container is resized small enough so the label won't fit on one line?


回答1:


You can access button's child widget — it's a GtkLabel in default setup, — and set various properties on it, e.g. wrap. However, since there is no height-for-width layout negotiation in GTK+ 2.x, what you want exactly can be difficult / close to impossible to achieve. Note that you can also replace the button's child if you want.




回答2:


I also got that working this way (using GtkSharp)

RadioButton rb;

/* Initialize the radio button ... */

//Set its wrap mode
(rb.Child as Gtk.Label).Wrap = true;
(rb.Child as Gtk.Label).LineWrap = true;
(rb.Child as Gtk.Label).LineWrapMode = Pango.WrapMode.Word;


来源:https://stackoverflow.com/questions/3152515/line-wrapping-in-gtkcheckbutton-or-gtkradiobutton-labels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!