seanscal
seanscal

Reputation: 568

List Formatting in Tkinter Text Box

I was just wondering if there was a way to get each of the elements in a list to display on separate lines, or with a line in between them in a text box in TKinter. What I have right now is simple code which draws from another file but I am not sure about how to go about this.

My code is this:

gui = compare.GCCCOMPARE.compare(mygcccompare)

root = Tk()
text = Text(root)
text.insert(INSERT,  gui)
text.pack() 
root.mainloop()

Where gui is the list.

What I get in the Text Box is this:

["Parameter Change between files 0 and 1 :  {'LPSUM': [(233, 42), '(253, 196)']}", "Parameter Change between files 1 and 2 :  {'LPSUM': [(253, 196), '(15, 194)']}", "Parameter Change between files 2 and 3 :  {'LPSUM': [(15, 194), '(229, 92)'],}"]

But what I want is:

["Parameter Change between files 0 and 1 :  {'LPSUM': [(233, 42), '(253, 196)']}", 

"Parameter Change between files 1 and 2 :  {'LPSUM': [(253, 196), '(15, 194)']}", 

"Parameter Change between files 2 and 3 :  {'LPSUM': [(15, 194), '(229, 92)']}"]

Upvotes: 0

Views: 1238

Answers (1)

seanscal
seanscal

Reputation: 568

("\n".join(map(str, listname)))

This is what I was looking for. If anyone seems to have a question like this on formatting a list so that each element is on a new line, this code will work for you

Upvotes: 2

Related Questions