'How do you get Tkinter to stop reading text at a specific character in python using .get()?
How do you get Tkinter to stop reading text at a specific character in python using .get()? I tried using
.get(1.0, "end-5c")
but it did not work because the text is always changing.
Solution 1:[1]
Use the text widget mark. See mark_set, mark_names and so on. This puts a mark in the text that will flow with the text.
text.mark_set('mymark', 2.2)
text.get(1.0, 'mymark')
The above would put a mark in on the second line after the second character and then get the text from the start to that mark. If you insert text between these commands, the mark position will move and can be read using text.index('mymark') if you need to know the actual index.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | patthoyts |
