2016-03-14 17 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()