2016-03-14 42 views
0

有什麼辦法可以在tkinter中設置列表框的固定線路長度嗎?所以當插入一個更大尺寸的字符串時,它會繼續到下一行?固定線路 - 列表框

回答

0

不,沒有辦法讓列表框中的項目包裝成兩行或多行。

0

看到的線比最寬可能的列表框寬是使用水平滾動條,這樣的唯一方法:

#!/usr/bin/env python3 
from tkinter import * 
from tkinter import ttk 
root = Tk() 
listo = Listbox(root, background='white', width=100) 
listo.grid(column=0, row=0, sticky=(N, W, E, S)) 
ybar = ttk.Scrollbar(root, orient=VERTICAL, command=listo.yview) 
ybar.grid(column=1, row=0, sticky=(N, W, E, S)) 
xbar = ttk.Scrollbar(root, orient=HORIZONTAL, command=listo.xview) 
xbar.grid(column=0, row=1, columnspan=2, sticky=(N, W, E, S)) 
listo["yscrollcommand"] = ybar.set 
listo["xscrollcommand"] = xbar.set 
listo.insert('end', "When, in the course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume, among the nations of the earth, that separate and equal station to which the laws of Nature and of Nature's God entitle them...") 
root.mainloop()