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