9
A
回答
0
使用格莱德编辑:
- 在林间空地编辑器中选择您的ScrolledWindow(你已经挤满的TextView到ScrolledWindow,不是吗:),如果不是 - 选择的TextView? )。
- 选择的Widget调性质 - >常见标签。
- 查找并调整边框宽度属性,以您的喜好。
从代码:
调用容器控件的set_border_width(width)
的方法(ScrolledWindow或的TextView)
注意,在任何情况下文本区将不完全像进入这取决于正在使用的gtk +主题。
0
使用gtk.ScrolledWindow.set_shadow_type(type=gtk.SHADOW_ETCHED_IN)
会改善外观,但不符合gtk.Entry
的风格。
如果放置在一个窗口或窗格中,被击倒的窗口或textview的边界不是问题,但是如果目标是创建一个带有多行输入字段的窗体,它会变得很难看。这里是一个黑客工具,可以做的伎俩......
import gtk
# create an entry widget that we use for appearances only
e=gtk.Entry()
e.set_size_request(width=250, height=150)
# create a texview and accompaying label
lbl = gtk.Label(str="Comments: ")
lbl.set_alignment(xalign=1, yalign=0)
field = gtk.TextView(buffer=None)
field.set_wrap_mode(wrap_mode=gtk.WRAP_WORD) # or gtk.WRAP_CHAR
# we need a scroll window
sw = gtk.ScrolledWindow(hadjustment=None, vadjustment=None)
sw.set_border_width(border_width=4)
sw.set_size_request(width=250, height=150)
sw.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC)
sw.add(field)
# create more widgets as needed for form here...
lbl2 = gtk.Label(str="email: ")
lbl2.set_alignment(xalign=1, yalign=0)
field2 = gtk.Entry()
# put everything in a table so the fields and labels are all aligned
tbl = gtk.Table(rows=1, columns=2, homogeneous=False)
tbl.attach(lbl, left_attach=0, right_attach=1, top_attach=0, bottom_attach=1, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL, xpadding=0, ypadding=0)
# sw and e must be attached in this order, the reverse will not work
tbl.attach(sw, left_attach=1, right_attach=2, top_attach=0, bottom_attach=1, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL, xpadding=0, ypadding=0)
tbl.attach(e, left_attach=1, right_attach=2, top_attach=0, bottom_attach=1, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL, xpadding=0, ypadding=0)
# comment out previous line to see difference
# attach other widgets here...
tbl.attach(lbl2, left_attach=0, right_attach=1, top_attach=1, bottom_attach=2, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL, xpadding=0, ypadding=0)
tbl.attach(field2, left_attach=1, right_attach=2, top_attach=1, bottom_attach=2, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL, xpadding=0, ypadding=0)
# display it!
window = gtk.Window()
window.set_default_size(350, 200)
window.connect("destroy", lambda w: gtk.main_quit())
window.add(tbl)
window.show_all()
gtk.main()
需要说明的是滚动条(S)变得不可见;它可以被选择,并且滚动像往常一样工作。如果要在该字段中输入的数据倾向于不使用滚动,这可能是一个小问题。
6
年后...但在网上搜索仍然没有给这个问题很好的答案。
解决的办法很简单:只需创建一个GtkFrame
并添加GtkScrolledWindow
包含GtkTextView
,这里是Python的一些示例代码:
frame = Gtk.Frame()
scroll = Gtk.ScrolledWindow()
scroll.set_hexpand(True)
scroll.set_border_width(3)
textview = Gtk.TextView()
scroll.add(textview)
frame.add(scroll)
相关问题
- 1. GTK - 如何更新gtktextview/gtkentry? #C
- 2. GtkEntry和GtkTextView有什么区别?
- 3. HttpRequestMessage如何看起来像?
- 4. 如何使leftBarButtonItem看起来像backBarButtonItem?
- 5. 如何使UITableView看起来像这样
- 6. 如何使JTextField看起来像JLabel
- 7. 如何使SSIS包看起来像DTS
- 8. 如何使UITableView看起来像这样?
- 9. 如何使GUI看起来像这样?
- 10. 内容如何看起来像图像
- 11. 使autocompletetextview看起来像edittext
- 12. 使UICollectionView看起来像UITableView
- 13. 如何在iPhone看起来像花
- 14. 如何让TButton看起来像3d?
- 15. 如何让Gedit看起来像Textmate?
- 16. 如何让svn diff看起来像diff?
- 17. 如何让Grid看起来像CRM Grids?
- 18. UILabel如何看起来像UITableViewStyleGrouped?
- 19. 我如何让Eclipse看起来像Textmate?
- 20. 如何使图像看起来像按钮
- 21. 如何使链接看起来像使用HTML/CSS的标签?
- 22. 如何使用CSS使smartgwt看起来像gwtext
- 23. 看看看起来如何json
- 24. Java Swing看起来像Windows
- 25. Imageview看起来像mapview
- 26. WP8.1日历看起来像
- 27. wpf ListBox看起来像datagrid?
- 28. 使BorderPane看起来像一个圆圈
- 29. 使按钮看起来像文字
- 30. 使PyCharm看起来像崇高文本
为什么你想迷惑你的用户喜欢吗? – ptomato 2011-06-07 21:50:02
@ptomato我需要同样的事情。这不是混淆用户,而是不要混淆用户。我需要一个3行文本小部件,其行为与Entry小部件完全相同(但是有3行)。我能找到的唯一方法是修改一个TextView小部件... – xubuntix 2012-11-11 08:27:52