如何在 C 中禁用 GtkTextView 的编辑?
我尝试了这个,它生成了一个 TextView 窗口:
http://zetcode.com/tutorials/gtktutorial/ gtktextview/
但我不希望它可编辑。
顺便问一下,当文本溢出时如何显示滚动条?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查 http://library.gnome.org/devel/gtk/stable/GtkTextView .html:
有一个
gtk_text_view_set_editable
函数。您可以通过将滚动条添加到
GtkScrolledWindow
来向小部件添加滚动条。例如:然后不要用视图调用 pack_start,而是用滚动调用它。
对于居中,
GtkScrolledWindow
不是顶级窗口,因此它的位置取决于父容器(示例中的VBox
)。有用于填充等的pack_start
参数,这可能会得到你想要的。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: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 (aVBox
in the example). There are parameters ofpack_start
for padding etc which might get what you want.