Tkinter :: Text :: Class Text
[hide private]
[frames] | no frames]

Class Text

source code

  Misc --+        
         |        
BaseWidget --+    
             |    
      Pack --+    
             |    
     Place --+    
             |    
      Grid --+    
             |    
        Widget --+
                 |
                Text

Text widget which can display text in various forms.

Nested Classes [hide private]

Inherited from Misc: getdouble, getint


Instance Methods [hide private]
  __init__(self, master=None, cnf={}, **kw)
Construct a text widget with the parent MASTER.
  bbox(self, *args)
Return a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the index in ARGS.
  compare(self, index1, op, index2)
Return whether between index INDEX1 and index INDEX2 the relation OP is satisfied.
  debug(self, boolean=None)
Turn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.
  delete(self, index1, index2=None)
Delete the characters between INDEX1 and INDEX2 (not included).
  dlineinfo(self, index)
Return tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX.
  dump(self, index1, index2=None, command=None, **kw)
Return the contents of the widget between index1 and index2.
  edit(self, *args)
Internal method
  edit_modified(self, arg=None)
Get or Set the modified flag
  edit_redo(self)
Redo the last undone edit
  edit_reset(self)
Clears the undo and redo stacks
  edit_separator(self)
Inserts a separator (boundary) on the undo stack.
  edit_undo(self)
Undoes the last edit action
  get(self, index1, index2=None)
Return the text from INDEX1 to INDEX2 (not included).
  image_cget(self, index, option)
Return the value of OPTION of an embedded image at INDEX.
  image_configure(self, index, cnf=None, **kw)
Configure an embedded image at INDEX.
  image_create(self, index, cnf={}, **kw)
Create an embedded image at INDEX.
  image_names(self)
Return all names of embedded images in this widget.
  index(self, index)
Return the index in the form line.char for INDEX.
  insert(self, index, chars, *args)
Insert CHARS before the characters at INDEX.
  mark_gravity(self, markName, direction=None)
Change the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT).
  mark_names(self)
Return all mark names.
  mark_next(self, index)
Return the name of the next mark after INDEX.
  mark_previous(self, index)
Return the name of the previous mark before INDEX.
  mark_set(self, markName, index)
Set mark MARKNAME before the character at INDEX.
  mark_unset(self, *markNames)
Delete all marks in MARKNAMES.
  scan_dragto(self, x, y)
Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.
  scan_mark(self, x, y)
Remember the current X, Y coordinates.
  search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None)
Search PATTERN beginning from INDEX until STOPINDEX.
  see(self, index)
Scroll such that the character at INDEX is visible.
  tag_add(self, tagName, index1, *args)
Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS.
  tag_bind(self, tagName, sequence, func, add=None)
Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC.
  tag_cget(self, tagName, option)
Return the value of OPTION for tag TAGNAME.
  tag_config(self, tagName, cnf=None, **kw)
Configure a tag TAGNAME.
  tag_configure(self, tagName, cnf=None, **kw)
Configure a tag TAGNAME.
  tag_delete(self, *tagNames)
Delete all tags in TAGNAMES.
  tag_lower(self, tagName, belowThis=None)
Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.
  tag_names(self, index=None)
Return a list of all tag names.
  tag_nextrange(self, tagName, index1, index2=None)
Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME.
  tag_prevrange(self, tagName, index1, index2=None)
Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME.
  tag_raise(self, tagName, aboveThis=None)
Change the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.
  tag_ranges(self, tagName)
Return a list of ranges of text which have tag TAGNAME.
  tag_remove(self, tagName, index1, index2=None)
Remove tag TAGNAME from all characters between INDEX1 and INDEX2.
  tag_unbind(self, tagName, sequence, funcid=None)
Unbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.
  tk_textBackspace(self)
  tk_textIndexCloser(self, a, b, c)
  tk_textResetAnchor(self, index)
  tk_textSelectTo(self, index)
  window_cget(self, index, option)
Return the value of OPTION of an embedded window at INDEX.
  window_config(self, index, cnf=None, **kw)
Configure an embedded window at INDEX.
  window_configure(self, index, cnf=None, **kw)
Configure an embedded window at INDEX.
  window_create(self, index, cnf={}, **kw)
Create a window at INDEX.
  window_names(self)
Return all names of embedded windows in this widget.
  xview(self, *what)
Query and change horizontal position of the view.
  xview_moveto(self, fraction)
Adjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.
  xview_scroll(self, number, what)
Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).
  yview(self, *what)
Query and change vertical position of the view.
  yview_moveto(self, fraction)
Adjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.
  yview_pickplace(self, *what)
Obsolete function, use see.
  yview_scroll(self, number, what)
Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).

Inherited from BaseWidget: destroy

Inherited from BaseWidget (private): _do, _setup

Inherited from Misc: __getitem__, __setitem__, __str__, after, after_cancel, after_idle, bell, bind, bind_all, bind_class, bindtags, cget, clipboard_append, clipboard_clear, colormodel, columnconfigure, config, configure, deletecommand, event_add, event_delete, event_generate, event_info, focus, focus_displayof, focus_force, focus_get, focus_lastfor, focus_set, getboolean, getvar, grab_current, grab_release, grab_set, grab_set_global, grab_status, grid_bbox, grid_columnconfigure, grid_location, grid_propagate, grid_rowconfigure, grid_size, grid_slaves, image_types, keys, lift, lower, mainloop, nametowidget, option_add, option_clear, option_get, option_readfile, pack_propagate, pack_slaves, place_slaves, propagate, quit, register, rowconfigure, selection_clear, selection_get, selection_handle, selection_own, selection_own_get, send, setvar, size, slaves, tk_bisque, tk_focusFollowsMouse, tk_focusNext, tk_focusPrev, tk_menuBar, tk_setPalette, tk_strictMotif, tkraise, unbind, unbind_all, unbind_class, update, update_idletasks, wait_variable, wait_visibility, wait_window, waitvar, winfo_atom, winfo_atomname, winfo_cells, winfo_children, winfo_class, winfo_colormapfull, winfo_containing, winfo_depth, winfo_exists, winfo_fpixels, winfo_geometry, winfo_height, winfo_id, winfo_interps, winfo_ismapped, winfo_manager, winfo_name, winfo_parent, winfo_pathname, winfo_pixels, winfo_pointerx, winfo_pointerxy, winfo_pointery, winfo_reqheight, winfo_reqwidth, winfo_rgb, winfo_rootx, winfo_rooty, winfo_screen, winfo_screencells, winfo_screendepth, winfo_screenheight, winfo_screenmmheight, winfo_screenmmwidth, winfo_screenvisual, winfo_screenwidth, winfo_server, winfo_toplevel, winfo_viewable, winfo_visual, winfo_visualid, winfo_visualsavailable, winfo_vrootheight, winfo_vrootwidth, winfo_vrootx, winfo_vrooty, winfo_width, winfo_x, winfo_y

Inherited from Pack: forget, info, pack, pack_configure, pack_forget, pack_info

Inherited from Place: place, place_configure, place_forget, place_info

Inherited from Grid: grid, grid_configure, grid_forget, grid_info, grid_remove, location


Class Variables [hide private]

Inherited from Misc: _noarg_

Inherited from Misc (private): _subst_format, _subst_format_str, _tclCommands


Method Details [hide private]

__init__(self, master=None, cnf={}, **kw)
(Constructor)

source code 
Construct a text widget with the parent MASTER.

STANDARD OPTIONS

    background, borderwidth, cursor,
    exportselection, font, foreground,
    highlightbackground, highlightcolor,
    highlightthickness, insertbackground,
    insertborderwidth, insertofftime,
    insertontime, insertwidth, padx, pady,
    relief, selectbackground,
    selectborderwidth, selectforeground,
    setgrid, takefocus,
    xscrollcommand, yscrollcommand,

WIDGET-SPECIFIC OPTIONS

    autoseparators, height, maxundo,
    spacing1, spacing2, spacing3,
    state, tabs, undo, width, wrap,

Overrides: BaseWidget.__init__

bbox(self, *args)

source code 
Return a tuple of (x,y,width,height) which gives the bounding box of the visible part of the character at the index in ARGS.
Overrides: Misc.grid_bbox

compare(self, index1, op, index2)

source code 
Return whether between index INDEX1 and index INDEX2 the relation OP is satisfied. OP is one of <, <=, ==, >=, >, or !=.

debug(self, boolean=None)

source code 
Turn on the internal consistency checks of the B-Tree inside the text widget according to BOOLEAN.

delete(self, index1, index2=None)

source code 
Delete the characters between INDEX1 and INDEX2 (not included).

dlineinfo(self, index)

source code 
Return tuple (x,y,width,height,baseline) giving the bounding box and baseline position of the visible part of the line containing the character at INDEX.

dump(self, index1, index2=None, command=None, **kw)

source code 

Return the contents of the widget between index1 and index2.

The type of contents returned in filtered based on the keyword parameters; if 'all', 'image', 'mark', 'tag', 'text', or 'window' are given and true, then the corresponding items are returned. The result is a list of triples of the form (key, value, index). If none of the keywords are true then 'all' is used by default.

If the 'command' argument is given, it is called once for each element of the list of triples, with the values of each triple serving as the arguments to the function. In this case the list is not returned.

edit(self, *args)

source code 

Internal method

This method controls the undo mechanism and the modified flag. The exact behavior of the command depends on the option argument that follows the edit argument. The following forms of the command are currently supported:

edit_modified, edit_redo, edit_reset, edit_separator and edit_undo

edit_modified(self, arg=None)

source code 

Get or Set the modified flag

If arg is not specified, returns the modified flag of the widget. The insert, delete, edit undo and edit redo commands or the user can set or clear the modified flag. If boolean is specified, sets the modified flag of the widget to arg.

edit_redo(self)

source code 

Redo the last undone edit

When the undo option is true, reapplies the last undone edits provided no other edits were done since then. Generates an error when the redo stack is empty. Does nothing when the undo option is false.

edit_reset(self)

source code 
Clears the undo and redo stacks

edit_separator(self)

source code 

Inserts a separator (boundary) on the undo stack.

Does nothing when the undo option is false

edit_undo(self)

source code 

Undoes the last edit action

If the undo option is true. An edit action is defined as all the insert and delete commands that are recorded on the undo stack in between two separators. Generates an error when the undo stack is empty. Does nothing when the undo option is false

get(self, index1, index2=None)

source code 
Return the text from INDEX1 to INDEX2 (not included).

image_cget(self, index, option)

source code 
Return the value of OPTION of an embedded image at INDEX.

image_configure(self, index, cnf=None, **kw)

source code 
Configure an embedded image at INDEX.

image_create(self, index, cnf={}, **kw)

source code 
Create an embedded image at INDEX.

image_names(self)

source code 
Return all names of embedded images in this widget.
Overrides: Misc.image_names

index(self, index)

source code 
Return the index in the form line.char for INDEX.

insert(self, index, chars, *args)

source code 
Insert CHARS before the characters at INDEX. An additional tag can be given in ARGS. Additional CHARS and tags can follow in ARGS.

mark_gravity(self, markName, direction=None)

source code 
Change the gravity of a mark MARKNAME to DIRECTION (LEFT or RIGHT). Return the current value if None is given for DIRECTION.

mark_names(self)

source code 
Return all mark names.

mark_next(self, index)

source code 
Return the name of the next mark after INDEX.

mark_previous(self, index)

source code 
Return the name of the previous mark before INDEX.

mark_set(self, markName, index)

source code 
Set mark MARKNAME before the character at INDEX.

mark_unset(self, *markNames)

source code 
Delete all marks in MARKNAMES.

scan_dragto(self, x, y)

source code 
Adjust the view of the text to 10 times the difference between X and Y and the coordinates given in scan_mark.

scan_mark(self, x, y)

source code 
Remember the current X, Y coordinates.

search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None)

source code 
Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.

see(self, index)

source code 
Scroll such that the character at INDEX is visible.

tag_add(self, tagName, index1, *args)

source code 
Add tag TAGNAME to all characters between INDEX1 and index2 in ARGS. Additional pairs of indices may follow in ARGS.

tag_bind(self, tagName, sequence, func, add=None)

source code 

Bind to all characters with TAGNAME at event SEQUENCE a call to function FUNC.

An additional boolean parameter ADD specifies whether FUNC will be called additionally to the other bound function or whether it will replace the previous function. See bind for the return value.

tag_cget(self, tagName, option)

source code 
Return the value of OPTION for tag TAGNAME.

tag_config(self, tagName, cnf=None, **kw)

source code 
Configure a tag TAGNAME.

tag_configure(self, tagName, cnf=None, **kw)

source code 
Configure a tag TAGNAME.

tag_delete(self, *tagNames)

source code 
Delete all tags in TAGNAMES.

tag_lower(self, tagName, belowThis=None)

source code 
Change the priority of tag TAGNAME such that it is lower than the priority of BELOWTHIS.

tag_names(self, index=None)

source code 
Return a list of all tag names.

tag_nextrange(self, tagName, index1, index2=None)

source code 
Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched forward from INDEX1.

tag_prevrange(self, tagName, index1, index2=None)

source code 
Return a list of start and end index for the first sequence of characters between INDEX1 and INDEX2 which all have tag TAGNAME. The text is searched backwards from INDEX1.

tag_raise(self, tagName, aboveThis=None)

source code 
Change the priority of tag TAGNAME such that it is higher than the priority of ABOVETHIS.

tag_ranges(self, tagName)

source code 
Return a list of ranges of text which have tag TAGNAME.

tag_remove(self, tagName, index1, index2=None)

source code 
Remove tag TAGNAME from all characters between INDEX1 and INDEX2.

tag_unbind(self, tagName, sequence, funcid=None)

source code 
Unbind for all characters with TAGNAME for event SEQUENCE the function identified with FUNCID.

tk_textBackspace(self)

source code 
None

tk_textIndexCloser(self, a, b, c)

source code 
None

tk_textResetAnchor(self, index)

source code 
None

tk_textSelectTo(self, index)

source code 
None

window_cget(self, index, option)

source code 
Return the value of OPTION of an embedded window at INDEX.

window_config(self, index, cnf=None, **kw)

source code 
Configure an embedded window at INDEX.

window_configure(self, index, cnf=None, **kw)

source code 
Configure an embedded window at INDEX.

window_create(self, index, cnf={}, **kw)

source code 
Create a window at INDEX.

window_names(self)

source code 
Return all names of embedded windows in this widget.

xview(self, *what)

source code 
Query and change horizontal position of the view.

xview_moveto(self, fraction)

source code 
Adjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.

xview_scroll(self, number, what)

source code 
Shift the x-view according to NUMBER which is measured in "units" or "pages" (WHAT).

yview(self, *what)

source code 
Query and change vertical position of the view.

yview_moveto(self, fraction)

source code 
Adjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.

yview_pickplace(self, *what)

source code 
Obsolete function, use see.

yview_scroll(self, number, what)

source code 
Shift the y-view according to NUMBER which is measured in "units" or "pages" (WHAT).