Tkinter.Text can never be empty?

H

Harry Pehkonen

While setting up some unit tests, I came to the conclusion that a
Tkinter Text widget can never be empty, but will always (?) contain a
\n. Here is a brief example:

My apologies, but I have not checked whether or not this can be
reproduced in Tcl/Tk (which I think might have been appropriate).

My question is: Is there *always* a trailing \n, is this a bug, or am
I doing something silly?

Thanks!
Harry.
 
V

vincent wehren

| While setting up some unit tests, I came to the conclusion that a
| Tkinter Text widget can never be empty, but will always (?) contain a
| \n. Here is a brief example:
|
| >>> import Tkinter
| >>> t = Tkinter.Text()
| >>> t.get(0.0, Tkinter.END)
| '\n'
| >>> t.delete(0.0, Tkinter.END)
| >>> t.get(0.0, Tkinter.END)
| '\n'
| >>>
|
| My apologies, but I have not checked whether or not this can be
| reproduced in Tcl/Tk (which I think might have been appropriate).
|
| My question is: Is there *always* a trailing \n, is this a bug, or am
| I doing something silly?

Nope, this is one of the idiosyncrasies of our friend the Text widget;
there's always this immortal LF at the end.

Vincent Wehren
|
| Thanks!
| Harry.
 
H

Harry Pehkonen

| >>> t = Tkinter.Text()
| >>> t.get(0.0, Tkinter.END)
'\n'
| My question is: Is there *always* a trailing \n, is this a bug, or am
| I doing something silly?

Nope, this is one of the idiosyncrasies of our friend the Text widget;
there's always this immortal LF at the end.

Vincent Wehren

Thanks, Vincent :D

Harry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top