Page 298 -
P. 298
guis and data
Large Text fields are harder to handle
So Text fields should work the same way, right? Well, actually, they don’t.
The designers of tkinter figured people might want to access particular lines
and columns in Text fields. This means that while Entry fields use a single
number to index the contents of the field, Text fields use a string, in the form
row.column:
This first character has index “1.0"
This means from the ROW=1 Row 1.
Unlike Entry() fields, you
can't just use get() to and COLUMN=0, which is the
get the entire contents. first character in the field.
my_large_field.get("1.0", END)
This will return
This will return the entire ALL of the text
contents of the field. in the T ext field.
Column 0.
Once you understand how Text indexes work, you’ll see that you can insert
and delete text from them in a very similar way to Entry fields:
my_large_field.delete("1.0", END)
This will clear the field.
my_large_field.insert("1.0", "Some text")
This will insert the text at Be careful how
the start of the field. you number
rows and
columns in
Now that you know how to create text fields and Text() fields.
control the text they contain, you’re ready to Rows begin at 1, but columns
build the Head-Ex application. begin at 0.
you are here 4 263