Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating a new line on a textbox in tkinter

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

like image 936
Tom Lowbridge Avatar asked Feb 23 '16 12:02

Tom Lowbridge


People also ask

Which widget is used for multi-line text field?

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.

How do you draw a horizontal line in tkinter?

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.

Which widget is used in tkinter single line input?

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.


1 Answers

You have just to add \n :

namebox.insert(END, names + '\n')
like image 161
Kenly Avatar answered Sep 21 '22 00:09

Kenly