I'm trying to create a simple notepad, but I have one small problem:
when I try to see if the text of an object Text
is empty or not:
if text_area.get(0.0, tkinter.END) != "":
print("Text não vazio") # é sempre executado
When I try to use the len
function to control the length of the text, it returns 1.
What is this default character after all? My solution would be to control the length of the text with 1 (or maybe better, if the length is greater than 1), and if it returns True, it means that it is "empty".
Now, why does Python , or rather the tkinter
library provide an end-of-text indicator, ie tkinter.END
, not start? Why do I have to put 0.0 (and not tkinter.START
)?
(Compared for example to the Java language, and in particular to its Swing bookstore, the tkinter bookstore is really unintuitive, even frankly frankly)