Learning python through a book, and tkinter.END is used in a block of code without being explained
import tkinter
def count(text, out_data):
""" Update out_data with the total number of As, Ts, Cs, and Gs found in text."""
data = text.get('0.0', **tkinter.END**)
counts = {}
for char in 'ATCG':
counts[char] = data.count(char)
out_data.set('Num As: {0} Num Ts: {1} Num Cs: {2} Num Gs: {3}'.format(
counts['A'], counts['T'], counts['C'], counts['G']))
...
I've looked online, and I only run across examples of it, never mentioning it's function.
I tried help(tkinter)
in a shell and got END = 'end'
which wasn't very useful.
If more code is required, just let me know. Didn't want to post the entire code making you pointlessly read more for no reason.
It doesn't "do" anything. It is a constant, the literal string "end". In this context it represents the point immediately after the last character entered by the user. The function get
on a text widget requires two values: a starting position and an ending position.
Note: in the line text.get('0.0', tkinter.END)
, '0.0'
is invalid (though, tkinter gratiously accepts it, and treats it the same as '1.0'
). Text indexes are of the form line.character. Lines start counting at 1, characters start at zero. So, the first character is '1.0'
, not '0.0'
.
It's just a constant.
The Python tkinter library is a wrapper around tk, so you'll want to reference the source documentation, which can be found at: http://www.tkdocs.com/tutorial/text.html#basics.
For your question, see the section on Retrieving the Text. In their Python example, they don't even use the constant:
thetext = text.get('1.0', 'end')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With