在我正在运行的项目的源代码中,我有一个生成字符串列表的进程。我试图将此列表放入Tkinter列表框以便于排序,但是当我这样做时,列表全部插入到一行中,我找不到将单个单词分隔到列表框中的不同行的方法。我对任何事情都持开放态度。下面我附上一个我想要做的例子:
from Tkinter import *
app = Tk()
app.geomtery("500x700")
app.title("ListBox")
names = ["Greg", "Earl", "Harry", "Bob"]
box = Listbox(app)
# Right here is where I am stuck
box.insert(END, names)
box.pack()
app.mainloop()
答案 0 :(得分:1)
你可以这样做:
from Tkinter import *
app = Tk()
app.geometry("500x700")
app.title("ListBox")
names = ["Greg", "Earl", "Harry", "Bob"]
box = Listbox(app)
# Right here is where I am stuck
for name in names:
box.insert(END, name)
box.pack()
app.mainloop()
答案 1 :(得分:1)
# Right here is where I am stuck
for i in names:
box.insert(END, i)
和
app.geometry("500x700")