aboutsummaryrefslogtreecommitdiff
path: root/demos/triangles.tcl
diff options
context:
space:
mode:
authorlecoanet2004-05-07 15:31:01 +0000
committerlecoanet2004-05-07 15:31:01 +0000
commit9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7 (patch)
tree842972357fdc905c7353dacf88a10e78427b96d8 /demos/triangles.tcl
parent752ff8735f731e8d37fb1bea60b0323af1a1ec06 (diff)
downloadtkzinc-9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7.zip
tkzinc-9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7.tar.gz
tkzinc-9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7.tar.bz2
tkzinc-9f0d489e9cda59a8ed026be96fa56f9ecc1a33f7.tar.xz
Switched from pack to grid; Demos are put in a namespace; No more name aliases for fonts
Diffstat (limited to 'demos/triangles.tcl')
-rw-r--r--demos/triangles.tcl60
1 files changed, 31 insertions, 29 deletions
diff --git a/demos/triangles.tcl b/demos/triangles.tcl
index d106bf1..7326f32 100644
--- a/demos/triangles.tcl
+++ b/demos/triangles.tcl
@@ -5,42 +5,44 @@ if {![info exists zincDemo]} {
error "This script should be run from the zinc-widget demo."
}
-set w .triangles
-catch {destroy $w}
-toplevel $w
-wm title $w "Zinc Triangles Demonstration"
-wm iconname $w Triangles
+namespace eval trianglesDemo {
+ variable w .triangles
+ catch {destroy $w}
+ toplevel $w
+ wm title $w "Zinc Triangles Demonstration"
+ wm iconname $w Triangles
-frame $w.buttons
-pack $w.buttons -side bottom -fill x -pady 2m
-button $w.buttons.dismiss -text Dismiss -command "destroy $w"
-button $w.buttons.code -text "See Code" -command "showCode $w"
-pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
+ grid [button $w.dismiss -text Dismiss -command "destroy $w"] -row 2 -column 0 -pady 10
+ grid [button $w.code -text "See Code" -command "showCode $w"] -row 2 -column 1 -pady 10
+ variable defaultfont [font create -family Helvetica -size 16 -weight normal]
-set defaultfont [font create -family Helvetica -size 10 -weight bold]
+ grid [zinc $w.zinc -width 700 -height 300 -font $defaultfont -render 1 -borderwidth 3 -relief sunken] \
+ -row 1 -column 0 -columnspan 2 -sticky news
+ grid columnconfigure $w 0 -weight 1
+ grid columnconfigure $w 1 -weight 1
+ grid rowconfigure $w 1 -weight 2
+
-zinc $w.zinc -width 700 -height 300 -font 10x20 -render 1 -borderwidth 3 -relief sunken
-pack $w.zinc
+ # 6 equilateral triangles around a point
+ $w.zinc add text 1 -position {40 10} -text "Triangles item without transparency"
-# 6 equilateral triangles around a point
-$w.zinc add text 1 -position {5 10} -text "Triangles item without transparency"
+ variable x0 200
+ variable y0 150
+ variable coords [list "$x0 $y0"]
+ for {set i 0} {$i<=6} {incr i} {
+ set angle [expr $i * 6.28/6]
+ lappend coords "[expr $x0 + 100 * cos($angle)] [expr $y0 - 100 * sin ($angle)]"
+ }
-set x0 200
-set y0 150
-set coords [list "$x0 $y0"]
-for {set i 0} {$i<=6} {incr i} {
- set angle [expr $i * 6.28/6]
- lappend coords "[expr $x0 + 100 * cos($angle)] [expr $y0 - 100 * sin ($angle)]"
-}
-
-set tr1 [$w.zinc add triangles 1 $coords -fan 1 -colors {white yellow red magenta blue cyan green yellow} -visible 1]
+ set tr1 [$w.zinc add triangles 1 $coords -fan 1 -colors {white yellow red magenta blue cyan green yellow} -visible 1]
-$w.zinc add text 1 -position {370 10} -text "Triangles item with transparency"
+ $w.zinc add text 1 -position {370 10} -text "Triangles item with transparency"
-# using the clone method to make a copy and then modify the clone"colors
-set tr2 [$w.zinc clone $tr1]
-$w.zinc translate $tr2 300 0
-$w.zinc itemconfigure $tr2 -colors {white;50 yellow;50 red;50 magenta;50 blue;50 cyan;50 green;50 yellow;50}
+ # using the clone method to make a copy and then modify the clone"colors
+ set tr2 [$w.zinc clone $tr1]
+ $w.zinc translate $tr2 300 0
+ $w.zinc itemconfigure $tr2 -colors {white;50 yellow;50 red;50 magenta;50 blue;50 cyan;50 green;50 yellow;50}
+}