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
A text widget provides a multi-line text area for the user. The text widget instance is created with the help of the text class. It is also used to display text lines and also allows editing the text.
Tkinter Canvas widget can be used for multiple purposes such as drawing shapes, objects, creating graphics and images. To draw a line on a Canvas, we can use create_line(x,y,x1,y1, **options) method.
The Entry widget is used to accept single-line text strings from a user. If you want to display multiple lines of text that can be edited, then you should use the Text widget.
You have just to add \n
:
namebox.insert(END, names + '\n')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With