60 likes | 234 Views
Tkinter Text Widget. Dick Steflik CS360. Text 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. Indices.
E N D
Tkinter Text Widget Dick Steflik CS360
Text 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
Indices • 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 (“@x,y”) • embedded object names (images, widgets) • expressions (+n chars, -n chars, +n lines, linestart, lineend, wordstart, wordend)
Marks • Invisible objects embedded in the widget’s 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
Tags • associate a display styles or event callbacks with ranges of text • tag_config background bgstipple borderwidth fgstipple font foregroung justify lmargin1 lmargin2 offset overstrike relief rmargin spacing1 spacing2 spacing3 tabs underline underline wrap
Methods mark_unset(name) scan_dragto(x,y) scan_mark(x,y) search(lots of parameters) see(index) tag_add(tagName, index) tag_bind(tagName,sequence, func, add=None) tag_cget(tagName, option) tag_config(tagName, cnf={} KW tag_delete(tagNames) tag_lower(tagName, belowThis=None) tag_names(index=None) tag_nextRange(tagName,index1, index2=None) tag_prevrange(tagName, index1,index2=None) tag_raise(tagName, aboveThis=None) tag_ranges(tagName) tag_remove(tagName, index1, index2=None) tag_unbind(tagName, sequence, funcid=None) window_cget(index, option) window_config(index, options) window_create(index,options) window_names() xview(what) xview_moveto(fraction) xview_scroll(number, what) bbox(index) compare(index1,op,index2) config(options) debug(boolean=None) delete(index1,index2) dlineinfo(index) dump(index1,index2,command) edit_modified(arg=None) edit_redo() edit_reset() edit_seperator() edit_undo() get(start,end=None) image_cget(index,option) image_configure(index, options) image_create(index,cnf={},kw) image_names() index(index) insert(index,text,tags) mark_gravity(self,name,direction) mark_names() mark_next() mark_previous() mark_set(name,index) yview(what) yview_moveto(fraction) yview_pickplace(what) yview_scroll(number, what)