Hi, all

Is there a way to get strings line by line from tk Text box?
I know there is readline for files, but i don't see anything like that for
tk Text box.

Only thing i see is text.get(float(index1), float(index2))
but it seems unhelpful in my case, although it is possible to get line by line by
incrementing index1 and 2 by 1, using loop
I won't be able to terminate it,
because there is no built-in method or attributes that would tell
how many times i need to loop until the loop variable reaches to the end of line.

Is there anyone can help me with this issue?!

I believe you can specify the second index as END... refer to the text widget indices guide here.

These mostly seem to be tk constants, but let me know if that is a misconception.

Thanks for reply

If i set the second index as END, then it will receive string data
from line#(index1) to the END..
but I need to read string line by line, not directly from certain line to the end.

If there is no method or attribute for this,
seems like string.split is the only option..

I believe you can specify the second index as END... refer to the text widget indices guide here.

These mostly seem to be tk constants, but let me know if that is a misconception.

Thanks for reply

If i set the second index as END, then it will receive string data
from line#(index1) to the END..
but I need to read string line by line, not directly from certain line to the end.

If there is no method or attribute for this,
seems like string.split is the only option..

Did you follow that link I posted? There are special ways to work with indices such as "line.end", lineend, etc... Try reading up on that page that is linked and see if those don't answer your question.

This question has already been answered. Start a new discussion instead.