问题
I have imported a list of names from a csv file and want to print each name a new line, how would i go about this as the program i have wrote prints it all on one line?
import csv
from tkinter import *
master=Tk()
file=open('Book1.csv')
qwerty=csv.reader(file)
people=[]
for column in qwerty:
people.append(column[0:7])
namelbl=Label(text='Name').grid(column=1,row=1)
namebox=Text(master,width=10)
namebox.grid(column=1,row=2)
namesList = [x[0] for x in people]
for names in sorted(namesList):
namebox.insert(END, names)
print(names)
master.mainloop()
apology's about the poor coding i'm new. Any help would be appreciated thanks
回答1:
You have just to add \n
:
namebox.insert(END, names + '\n')
来源:https://stackoverflow.com/questions/35577359/creating-a-new-line-on-a-textbox-in-tkinter