Title: Tkinter Text Widget
1Tkinter Text Widget
2Text Widget
- Formatted text display
- display formatted (fonts, embedded images,
embellishments like italics, bolding and
underscore) - use for multi line text input
- can be used as a text editor
3Indices
- Indices are used to point to positions in the
text managed by the widget - line/column
- 1.0 points to row 1 column 0 (the first
character of the area) - 2.10 row 2 character 10
- .end
- 2.end points to the newline char at the end
of line 2 - INSERT the insertion point
- CURRENT character closest to the mouse pointer
- END - points to the character just after the
last character in the buffer - user defined marks
- user defined tags
- SEL_FIRST, SEL_LAST selected character string
- window coordinates (_at_x,y)
- embedded object names (images, widgets)
- expressions (n chars, -n chars, n lines,
linestart, lineend, wordstart, wordend)
4Marks
- Invisible objects embedded in the widgets text.
Positioned between character cells and moves
along with the text. - INSERT a mark that represents the insertion
cursor - CURRENT a mark that represents the character
closest to the cursor. - user defined marks anywhere, must use mark_set
and mark_unset methods
5Tags
- associate a display styles or event callbacks
with ranges of text - tag_config
background bgstipple borderwidth fgstipple font fo
regroung justify lmargin1 lmargin2
offset overstrike relief rmargin spacing1 spacing2
spacing3 tabs underline underline wrap
6Methods
mark_unset(name) scan_dragto(x,y) scan_mark(x,y) s
earch(lots of parameters) see(index) tag_add(tagNa
me, index) tag_bind(tagName,sequence, func,
addNone) tag_cget(tagName, option) tag_config(tag
Name, cnf KW tag_delete(tagNames) tag_lower(tag
Name, belowThisNone) tag_names(indexNone) tag_ne
xtRange(tagName,index1, index2None) tag_prevrange
(tagName, index1,index2None) tag_raise(tagName,
aboveThisNone) tag_ranges(tagName) tag_remove(tag
Name, index1, index2None) tag_unbind(tagName,
sequence, funcidNone) window_cget(index,
option) window_config(index, options) window_creat
e(index,options) window_names() xview(what) xview_
moveto(fraction) xview_scroll(number, what)
bbox(index) compare(index1,op,index2) config(optio
ns) debug(booleanNone) delete(index1,index2) dlin
einfo(index) dump(index1,index2,command) edit_modi
fied(argNone) edit_redo() edit_reset() edit_seper
ator() edit_undo() get(start,endNone) image_cget(
index,option) image_configure(index,
options) image_create(index,cnf,kw) image_names
() index(index) insert(index,text,tags) mark_gravi
ty(self,name,direction) mark_names() mark_next() m
ark_previous() mark_set(name,index)
yview(what) yview_moveto(fraction) yview_pickplace
(what) yview_scroll(number, what)