Python3 Tkinter Text Widget INSERT on same line Python3 Tkinter Text Widget INSERT on same line tkinter tkinter

Python3 Tkinter Text Widget INSERT on same line


Problem is not insert() but print() which always add '\n' at the end - but it is natural.

You can use end="" to print text without '\n'

print( 'Hello: ', end='' ) 

or directly

sys.stdout.write( 'Hello: ' )

Or in insert() use

inputStr.strip('\n')

But it will remove all '\n' - even if you will need '\n' ie.

print( 'Hello:\n\n\n' ) 

You will never know if you have to remove last '\n' or not.