Issue 18246: tkinter.Text() add a newline to the content - bug? (original) (raw)
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information.
from tkinter import* root = Tk() text = Text() text.pack() text.insert(1.0, "Hello") text.get(1.0, END) 'Hello\n'
The tkinter.Text() widget add a newline (\n) to its content. Is this behavior a bug?
You omitted the crucial control experiment.
t2=tk.Text() t2.get(1.0, tk.END) '\n' Text widgets are initialized to end with \n. I suspect that this is an intentional invariant of tk Text widgets, done by tk itself and not out tkinter wrapper, even if not well documented in the tkinter doc strings.
.insert works as documented.
So unless you can determine that this initialization is a recent and unintentional change, we would not change it. Hence closing at least for now.
(G.P., if you think this is wrong, re-open)
PS. python-list mirrrored on comp.lang.python and gmane.comp.python.general is a better place to ask 'Is this a bug?' and similar questions.