[ Team LiB ] Previous Section Next Section

Text Operations

Table 36-9 describes the text widget operations, including some that are not discussed in this chapter. In the table, $t is a text widget:

Table 36-9. Operations for the text widget

$t bbox index

Returns the bounding box of the character at index. Four numbers are returned: x y width height.

$t cget option

Returns the value of the configuration option.

$t compare i1 op i2

Performs index comparison. i1 and i2 are indexes. op is one of < <= == >= > !=

$t configure ...

Queries or sets configuration options.

$t debug boolean

Enables consistency checking for B-tree code.

$t delete i1 ?i2? ?...?

Deletes from i1 up to, but not including i2. Just deletes the character at i1 if i2 is not specified. Deletes multiple ranges if specified.

$t dlineinfo index

Returns the bounding box, in pixels, of the display for the line containing index. Five numbers are returned: x y width height baseline.

$t dump ?options? i1 ?i2?

Returns the marks, tags, windows, images, and text contained in the widget. Options are -all, -command command, -image, -mark, -tag, -text, and -window.

$t edit modified ?boolean?

Queries or sets the widget's modified flag. (Tk 8.4)

$t edit redo

Reapplies the last undone edit action if the undo attribute is true. (Tk 8.4)

$t edit reset

Clears the undo and redo stacks. (Tk 8.4)

$t edit separator

Inserts a separator on the undo stack if the undo attribute is true. (Tk 8.4)

$t edit undo

Undoes the last edit action if the undo attribute is true. (Tk 8.4)

$t get i1 ?i2? ?...?

Returns the text from i1 to i2, or just the character at i1 if i2 is not specified. Returns multiple ranges as a list, if specified.

$t image cget option

Returns the value of the image option.

$t image configure ?options?

Queries or sets the configuration of an embedded image.

$t image create option value ...

Creates an embedded image. Options are described in Table 36-7 on page 547.

$t image names

Returns the names of all embedded images.

$t index index

Returns the numerical value of index.

$t insert index chars ?tags? ?chars tags? ...

Inserts chars at the specified index. If tags are specified, they are added to the new characters.

$t mark gravity name ?direction?

Queries or assigns a gravity direction to the mark name. direction, if specified, is left or right.

$t mark names

Returns a list of defined marks.

$t mark next index

Returns the mark after index.

$t mark previous index

Returns the mark before index.

$t mark set name index

Defines a mark name at the given index.

$t mark unset name1 ?name2 ...?

Deletes the named mark, or marks.

$t scan mark x y

Anchors a scrolling operation.

$t scan dragto x y

Scrolls based on a new position.

$t search ?switches? pattern index ?stopIndex?

Searches for pattern starting at index. The index of the start of the match is returned. Switches are described in Table 36-4 on page 544.

$t see index

Positions the display to view index.

$t tag add name i1 ?i2?

?i1 i2? ?i1 i2? ...

Adds the tag to i1 through, but not including i2, or just the character at i1 if i2 is not given.

$t tag bind name ?sequence? ?script?

Queries or defines bindings for the tag name.

$t tag cget name option

Returns the value of option for tag name.

$t tag configure name ...

Sets or queries the configuration of tag name.

$t tag delete tag1 ?tag2

...?

Deletes information for the named tags.

$t tag lower tag ?below?

Lowers the priority of tag to the lowest priority or to just below tag below.

$t tag names ?index?

Returns the names of the tags at the specified index, or in the whole widget, sorted from lowest to highest priority.

$t tag nextrange tag i1 ?i2?

Returns a list of two indices that are the next range of text with tag that starts at or after i1 and before index i2, or the end.

$t tag prevrange tag i1

?i2?

Returns a list of two indices that are the previous range of text with tag that ends at or before i1 and at or after index i2, or 1.0.

$t tag raise tag ?above?

Raises the priority of tag to the highest priority, or to just above the priority of tag above.

$t tag ranges tag

Returns a list describing all the ranges of tag.

$t tag remove tag i1 ?i2?

?i1 i2? ?i1 i2? ...

Removes tag from the range i1 up to, but not including i2, or just at i1 if i2 is not specified.

$t window cget win option

Returns the value of option for win.

$t window config win ...

Queries or modifies the configuration of the embedded window. win is a Tk pathname or an index.

$t window create ix args

Creates an embedded window at ix.

$t window names

Returns a list of windows embedded in $t.

$t xview

Returns two fractions between zero and one that describe the amount of text off-screen to the left and the amount of text displayed.

$t xview moveto fraction

Positions the text so fraction of the text is off screen to the left.

$t xview scroll num what

Scrolls num of what, which is units or pages.

$t yview

Returns two fractions between zero and one that describe the amount of text off-screen toward the beginning and the amount of text displayed.

$t yview moveto fraction

Positions the text so fraction of the text is off-screen toward the beginning.

$t yview scroll num what

Scrolls num of what, which is units or pages.

$t yview ?-pickplace? ix

Obsolete. Use the see operation, which is similar.

$t yview num

Obsolete. Position line num at the top of screen.

    [ Team LiB ] Previous Section Next Section