PyDocs

Nav

Graphical user interfaces with Tk

Text

tkinter

class
  • Text(master=None, cnf={}, **kw)
A Text widget displays and edits multi-line text. Portions of the text may be styled with tags, particular positions may be annotated with floating marks, and arbitrary images and other widgets may be embedded in the text. The widget also provides an unlimited undo/redo mechanism and supports peer widgets that share the same underlying data. Inherits from Widget, XView and YView, so the view can be scrolled horizontally and vertically with xview() and yview(). Refer to the Tk text manual page for the full list of options.
Members of Text

b

bbox
Return a tuple (x, y, width, height) giving the bounding box, in pixels, of the visible part of the character at index, or None if that character is not visible on the screen.

c

compare
Compare the positions of index1 and index2 using the relational operator op, which must be one of '<', '<=', '==', '>=', '>' or '!=', and return the boolean result.
count
Count the number of items of the requested kinds between index1 and index2; the count is negative if index1 is after index2.

d

debug
If boolean is omitted, return whether internal consistency checks of the B-tree data structure are enabled.
delete
Delete the range of characters from index1 up to but not including index2.
dlineinfo
Return a tuple (x, y, width, height, baseline) describing the display line that contains index: the first four values give the bounding box of the line in pixels and baseline gives the offset of the …
dump
Return the contents of the widget from index1 up to but not including index2 (or just the segment at index1 if index2 is omitted), including text and information about marks, tags, images and windows.

e

edit
Low-level wrapper around the Tk edit widget command that controls the undo/redo mechanism and the modified flag; args is the edit subcommand and its arguments.
edit_modified
If arg is omitted, return the current state of the modified flag as true or false; the flag is set automatically whenever the text is inserted or deleted.
edit_redo
Reapply the most recently undone edit action, provided no further edits have been made since, and move it back to the undo stack.
edit_reset
Clear the undo and redo stacks.
edit_separator
Push a separator onto the undo stack, marking a boundary between edit actions for undo and redo.
edit_undo
Undo the most recent edit action, that is, all the inserts and deletes recorded on the undo stack since the previous separator, and move it to the redo stack.

g

get
Return the text from index1 up to but not including index2 as a string.

i

image_cget
Return the current value of the configuration option option for the embedded image at index.
image_configure
Query or modify the configuration options of the embedded image at index, like configure() but applied to that image.
image_create
Embed an image at index and return the name assigned to this image instance, which may then be used as an index or passed to the other image_* methods.
image_names
Return a tuple of the names of all images embedded in the widget.
index
Return the position corresponding to index in the canonical 'line.char' form.
insert
Insert the string chars just before the character at index (if index is 'end', just before the final newline).

m

mark_gravity
If direction is omitted, return the gravity of mark markName, either 'left' or 'right'.
mark_names
Return a tuple of the names of all marks currently set in the widget.
mark_next
Return the name of the first mark at or after index, or None if there is none.
mark_previous
Return the name of the last mark at or before index, or None if there is none.
mark_set
Set the mark named markName to the position just before the character at index, creating the mark if it does not already exist.
mark_unset
Remove each of the marks named in markNames.

p

peer_create
Create a peer text widget with the path name newPathName that shares this widget’s underlying data (text, marks, tags, images and the undo stack).
peer_names
Return a tuple of the path names of this widget’s peers, not including the widget itself.

r

replace
Replace the range of characters from index1 up to but not including index2 with chars.

s

scan_dragto
Scroll the widget by 10 times the difference between x, y and the coordinates passed to the last scan_mark() call.
scan_mark
Record x, y and the current view, for use with later scan_dragto() calls.
search
Search for pattern starting at index and return the index of the first character of the first match, or an empty string if there is no match.
search_all
Like search(), but find every match in the searched range and return a tuple of the starting indices of all matches (empty if there are none).
see
Adjust the view so that the character given by index is visible.

t

tag_add
Add the tag tagName to the range of characters from index1 up to but not including the next index in args.
tag_bind
Bind the event sequence on characters tagged with tagName to the callback func, so that func is invoked when that event occurs over such a character.
tag_cget
Return the current value of the configuration option option for the tag tagName.
tag_config
Query or modify the configuration options of the tag tagName.
tag_configure
Query or modify the configuration options of the tag tagName.
tag_delete
Delete each of the tags named in tagNames, removing them from all characters and discarding their options and bindings.
tag_lower
Lower the priority of tag tagName so that it is just below the priority of belowThis, or to the lowest priority of all tags if belowThis is omitted.
tag_names
If index is omitted, return a tuple of the names of all tags defined in the widget; otherwise return only the names of the tags applied to the character at index.
tag_nextrange
Search forward from index1 (up to index2 if given) for the first range of characters tagged with tagName, and return a two-element tuple of its start and end indices, or an empty tuple if there is no…
tag_prevrange
Search backward from index1 (down to index2 if given) for the nearest preceding range of characters tagged with tagName, and return a two-element tuple of its start and end indices, or an empty tuple…
tag_raise
Raise the priority of tag tagName so that it is just above the priority of aboveThis, or to the highest priority of all tags if aboveThis is omitted.
tag_ranges
Return a tuple of indices describing all ranges of text tagged with tagName.
tag_remove
Remove the tag tagName from the characters from index1 up to but not including index2 (or from the single character at index1 if index2 is omitted).
tag_unbind
Remove the bindings of the event sequence on characters tagged with tagName.

w

window_cget
Return the current value of the configuration option option for the embedded window at index.
window_config
Query or modify the configuration options of the embedded window at index, like configure() but applied to that window.
window_configure
Query or modify the configuration options of the embedded window at index, like configure() but applied to that window.
window_create
Embed a window (any widget) at index.
window_names
Return a tuple of the names of all windows embedded in the widget.

y

yview_pickplace
Adjust the view so that the location given by what is visible.
0 Examples
No examples for tkinter/Text.
See Also
No see-alsos for tkinter/Text
0 Notes
No notes for Text