问题
I tried this one and it generates a TextView window:
http://zetcode.com/tutorials/gtktutorial/gtktextview/
But I don't want it to be editable.
BTW, how can I show the scroll bar when the text overflows?
回答1:
Check http://library.gnome.org/devel/gtk/stable/GtkTextView.html:
There's a gtk_text_view_set_editable
function.
You can add scrollbars to widgets by adding them to a GtkScrolledWindow
. Eg:
GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled), view);
And then instead of calling pack_start with view, call it with scrolled.
For centering, a GtkScrolledWindow
isn't a top-level window so its position depends on the parent container (a VBox
in the example). There are parameters of pack_start
for padding etc which might get what you want.
来源:https://stackoverflow.com/questions/2738897/how-can-i-disable-editting-for-gtktextview-in-c