OUTPUT BUFFER:
set w .help.general set base .help catch {destroy $w} #toplevel $w wm title $w "Text Demonstration - Display Styles" wm iconname $w "style" frame $w.buttons pack $w.buttons -side bottom -fill x -pady 2m button $w.buttons.dismiss -background red -text "Dismiss All" -command "destroy $base" button $w.buttons.ok -background green -text "OK" -command "destroy $w" pack $w.buttons.dismiss $w.buttons.ok -side left -expand 1 text $w.text -yscrollcommand "$w.scroll set" -setgrid true \ -width 70 -height 32 -wrap word scrollbar $w.scroll -command "$w.text yview" pack $w.scroll -side right -fill y pack $w.text -expand yes -fill both # Set up display styles $w.text tag configure bold -font {Courier 12 bold italic} $w.text tag configure big -font {Courier 14 bold} $w.text tag configure verybig -font {Helvetica 24 bold} if {[winfo depth $w] > 1} { $w.text tag configure color1 -background #a0b7ce $w.text tag configure color2 -foreground red $w.text tag configure raised -relief raised -borderwidth 1 $w.text tag configure sunken -relief sunken -borderwidth 1 } else { $w.text tag configure color1 -background black -foreground white $w.text tag configure color2 -background black -foreground white $w.text tag configure raised -background white -relief raised \ -borderwidth 1 $w.text tag configure sunken -background white -relief sunken \ -borderwidth 1 } $w.text tag configure bgstipple -background black -borderwidth 0 \ -bgstipple gray12 $w.text tag configure fgstipple -fgstipple gray50 $w.text tag configure underline -underline on $w.text tag configure overstrike -overstrike on $w.text tag configure right -justify right $w.text tag configure center -justify center $w.text tag configure super -offset 4p -font {Courier 10} $w.text tag configure sub -offset -2p -font {Courier 10} $w.text tag configure margins -lmargin1 12m -lmargin2 6m -rmargin 10m $w.text tag configure spacing -spacing1 10p -spacing2 2p \ -lmargin1 12m -lmargin2 6m -rmargin 10m $w.text insert end {Text widgets like this one allow you to display information in a variety of styles. Display styles are controlled using a mechanism called } $w.text insert end tags bold $w.text insert end {. Tags are just textual names that you can apply to one or more ranges of characters within a text widget. You can configure tags with various display styles. If you do this, then the tagged characters will be displayed with the styles you chose. The available display styles are: } $w.text insert end "\n1. Font." big $w.text insert end " You can choose any X font, " $w.text insert end large verybig $w.text insert end " or " $w.text insert end "small.\n" $w.text insert end "\n2. Color." big $w.text insert end " You can change either the " $w.text insert end background color1 $w.text insert end " or " $w.text insert end foreground color2 $w.text insert end "\ncolor, or " $w.text insert end both {color1 color2} $w.text insert end ".\n"