Text Description The Text class defines a new window and creates an instance of a text widget.. Additional options, described below, may be specified in the method call or in the option
Trang 1528 A P P E N D I X B T K I N T E R R E F ER E N C E
ciated widget For example, if first is 0.2 and last is 0.4, it means that the first part of the document visible in the window is 20% of the way through the document, and the last visible part is 40% of the way through
Text
Description
The Text class defines a new window and creates an instance of a text widget Additional options, described below, may be specified in the method call or in the option database to configure aspects of the text such as its default background color and relief The text
method returns the path name of the new window
A text widget displays one or more lines of text and allows that text to be edited Text widgets support four different kinds of annotations on the text: tags, marks, embedded win-dows and embedded images Tags allow different portions of the text to be displayed with dif-ferent fonts and colors In addition, Tcl commands can be associated with tags so that scripts are invoked when particular actions such as keystrokes and mouse button presses occur in par-ticular ranges of the text
The second form of annotation consists of marks, which are floating markers in the text Marks are used to keep track of various interesting positions in the text as it is edited The third form of annotation allows arbitrary windows to be embedded in a text widget The fourth form of annotation allows Tk images to be embedded in a text widget Many of the widget commands for texts take one or more indices as arguments An index
is a string used to indicate a particular place within a text, such as a place to insert characters
or one endpoint of a range of characters to delete
Inheritance
Text inherits from Widget.)
Shared options
Option (alias) Default
background (bg) SystemWindow
borderwidth (bd) 2
font (('MS', 'Sans', 'Serif'), '8')
foreground (fg) SystemWindowText
highlightbackground SystemButtonFace
highlightcolor SystemWindowFrame
highlightthickness 0