Reputation: 2962
I'm busy using tkinter in my python program, and I'm busy reading and then inserting into a text window, but there appears to be a line spacing between my input which shouldn't be there.
See following read to insert code:
def writer(self, Tk, textobject, n):
for line in textobject:
textwindow.insert(Tk.INSERT, line + "\n")
self.sleeper(n)
See output:
TEXT LINE 1
TEXT LINE 2
EDIT: See what output should be:
TEXT LINE 1
TEXT LINE 2
Upvotes: 0
Views: 596
Reputation: 2962
When using
textwindow.insert(Tk.INSERT, line + "\n")
There is no need to use
"\n"
As inserting a line creates its own new line already.
As such, I removed the "\n" and found that it worked perfectly.
Upvotes: 0
Reputation: 414
If you want the output to read TEXT LINE 1 TEXT LINE 2, remove the "\n".
Your code will look like:
def writer(self, Tk, textobject, n):
for line in textobject:
textwindow.insert(Tk.INSERT, line)
self.sleeper(n)
Upvotes: 1