summaryrefslogtreecommitdiffstats
path: root/library/demos/ctext.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/demos/ctext.tcl')
-rw-r--r--library/demos/ctext.tcl48
1 files changed, 24 insertions, 24 deletions
diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl
index 4b8c644..3eacdda 100644
--- a/library/demos/ctext.tcl
+++ b/library/demos/ctext.tcl
@@ -10,7 +10,7 @@ if {![info exists widgetDemo]} {
package require Tk
set w .ctext
-catch {destroy $w}
+destroy $w
toplevel $w
wm title $w "Canvas Text Demonstration"
wm iconname $w "Text"
@@ -34,7 +34,7 @@ pack $btns -side bottom -fill x
canvas $c -relief flat -borderwidth 0 -width 500 -height 350
pack $w.c -side top -expand yes -fill both
-set textFont {Helvetica 24}
+set textFont "Helvetica 24"
$c create rectangle 245 195 255 205 -outline black -fill red
@@ -56,14 +56,14 @@ $c bind text <2> "textPaste $c @%x,%y"
# to be edited.
proc mkTextConfigBox {w x y option value color} {
- set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \
+ set item [$w create rect $x $y [expr {$x + 30}] [expr {$y + 30}] \
-outline black -fill $color -width 1]
$w bind $item <1> "$w itemconf text $option $value"
$w addtag config withtag $item
}
proc mkTextConfigPie {w x y a option value color} {
- set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \
- -start [expr {$a-15}] -extent 30 -outline black -fill $color \
+ set item [$w create arc $x $y [expr {$x + 90}] [expr {$y + 90}] \
+ -start [expr {$a - 15}] -extent 30 -outline black -fill $color \
-width 1]
$w bind $item <1> "$w itemconf text $option $value"
$w addtag config withtag $item
@@ -73,20 +73,20 @@ set x 50
set y 50
set color LightSkyBlue1
mkTextConfigBox $c $x $y -anchor se $color
-mkTextConfigBox $c [expr {$x+30}] [expr {$y }] -anchor s $color
-mkTextConfigBox $c [expr {$x+60}] [expr {$y }] -anchor sw $color
-mkTextConfigBox $c [expr {$x }] [expr {$y+30}] -anchor e $color
-mkTextConfigBox $c [expr {$x+30}] [expr {$y+30}] -anchor center $color
-mkTextConfigBox $c [expr {$x+60}] [expr {$y+30}] -anchor w $color
-mkTextConfigBox $c [expr {$x }] [expr {$y+60}] -anchor ne $color
-mkTextConfigBox $c [expr {$x+30}] [expr {$y+60}] -anchor n $color
-mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color
+mkTextConfigBox $c [expr {$x + 30}] [expr {$y }] -anchor s $color
+mkTextConfigBox $c [expr {$x + 60}] [expr {$y }] -anchor sw $color
+mkTextConfigBox $c [expr {$x }] [expr {$y + 30}] -anchor e $color
+mkTextConfigBox $c [expr {$x + 30}] [expr {$y + 30}] -anchor center $color
+mkTextConfigBox $c [expr {$x + 60}] [expr {$y + 30}] -anchor w $color
+mkTextConfigBox $c [expr {$x }] [expr {$y + 60}] -anchor ne $color
+mkTextConfigBox $c [expr {$x + 30}] [expr {$y + 60}] -anchor n $color
+mkTextConfigBox $c [expr {$x + 60}] [expr {$y + 60}] -anchor nw $color
set item [$c create rect \
- [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \
+ [expr {$x + 40}] [expr {$y + 40}] [expr {$x + 50}] [expr {$y + 50}] \
-outline black -fill red]
$c bind $item <1> "$c itemconf text -anchor center"
-$c create text [expr {$x+45}] [expr {$y-5}] \
- -text {Text Position} -anchor s -font {Times 20} -fill brown
+$c create text [expr {$x + 45}] [expr {$y - 5}] \
+ -text "Text Position" -anchor s -font "Times 20" -fill brown
# Now create some items that allow the text's angle to be changed.
@@ -105,8 +105,8 @@ mkTextConfigPie $c $x $y 240 -angle 330 $color
mkTextConfigPie $c $x $y 270 -angle 0 $color
mkTextConfigPie $c $x $y 300 -angle 30 $color
mkTextConfigPie $c $x $y 330 -angle 60 $color
-$c create text [expr {$x+45}] [expr {$y-5}] \
- -text {Text Angle} -anchor s -font {Times 20} -fill brown
+$c create text [expr {$x + 45}] [expr {$y - 5}] \
+ -text "Text Angle" -anchor s -font "Times 20" -fill brown
# Lastly, create some items that allow the text's justification to be
# changed.
@@ -115,15 +115,15 @@ set x 350
set y 50
set color SeaGreen2
mkTextConfigBox $c $x $y -justify left $color
-mkTextConfigBox $c [expr {$x+30}] $y -justify center $color
-mkTextConfigBox $c [expr {$x+60}] $y -justify right $color
-$c create text [expr {$x+45}] [expr {$y-5}] \
- -text {Justification} -anchor s -font {Times 20} -fill brown
+mkTextConfigBox $c [expr {$x + 30}] $y -justify center $color
+mkTextConfigBox $c [expr {$x + 60}] $y -justify right $color
+$c create text [expr {$x + 45}] [expr {$y - 5}] \
+ -text "Justification" -anchor s -font "Times 20" -fill brown
$c bind config <Enter> "textEnter $c"
$c bind config <Leave> "$c itemconf current -fill \$textConfigFill"
-set textConfigFill {}
+set textConfigFill ""
proc textEnter {w} {
global textConfigFill
@@ -132,7 +132,7 @@ proc textEnter {w} {
}
proc textInsert {w string} {
- if {$string == ""} {
+ if {$string eq ""} {
return
}
catch {$w dchars text sel.first sel.last}