Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在列表中分隔单词Tkinter Listbox Python_Python_Listbox_Tkinter_Python 2.7 - Fatal编程技术网

在列表中分隔单词Tkinter Listbox Python

在列表中分隔单词Tkinter Listbox Python,python,listbox,tkinter,python-2.7,Python,Listbox,Tkinter,Python 2.7,在我正在运行的项目的源代码中,我有一个生成字符串列表的进程。我试图把这个列表放到一个Tkinter列表框中以便于排序,但是当我这样做时,列表都被插入到一行中,我找不到一种方法将单个单词分隔到列表框的另一行中。任何想法我都愿意接受。下面我附上一个我正在尝试做的例子: from Tkinter import * app = Tk() app.geomtery("500x700") app.title("ListBox") names = ["Greg", "Earl", "Harry", "Bo

在我正在运行的项目的源代码中,我有一个生成字符串列表的进程。我试图把这个列表放到一个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() 

这就是你可以做到的:

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()
在python中非常简单,不是吗 只需添加项目,而不是列表

# Right here is where I am stuck
for i in names:
    box.insert(END, i)


我想我差不多就是这么说的;)
app.geometry("500x700")