| 1 |
#!../src/bltwish |
| 2 |
|
| 3 |
package require BLT |
| 4 |
# -------------------------------------------------------------------------- |
| 5 |
# Starting with Tcl 8.x, the BLT commands are stored in their own |
| 6 |
# namespace called "blt". The idea is to prevent name clashes with |
| 7 |
# Tcl commands and variables from other packages, such as a "table" |
| 8 |
# command in two different packages. |
| 9 |
# |
| 10 |
# You can access the BLT commands in a couple of ways. You can prefix |
| 11 |
# all the BLT commands with the namespace qualifier "blt::" |
| 12 |
# |
| 13 |
# blt::graph .g |
| 14 |
# blt::table . .g -resize both |
| 15 |
# |
| 16 |
# or you can import all the command into the global namespace. |
| 17 |
# |
| 18 |
# namespace import blt::* |
| 19 |
# graph .g |
| 20 |
# table . .g -resize both |
| 21 |
# |
| 22 |
# -------------------------------------------------------------------------- |
| 23 |
if { $tcl_version >= 8.0 } { |
| 24 |
namespace import blt::* |
| 25 |
namespace import -force blt::tile::* |
| 26 |
} |
| 27 |
source scripts/demo.tcl |
| 28 |
|
| 29 |
if { [ file exists ./images/sample.gif] } { |
| 30 |
set src [image create photo -file ./images/sample.gif] |
| 31 |
} else { |
| 32 |
puts stderr "no image file" |
| 33 |
exit 0 |
| 34 |
} |
| 35 |
|
| 36 |
set width [image width $src] |
| 37 |
set height [image height $src] |
| 38 |
|
| 39 |
option add *Label.font *helvetica*10* |
| 40 |
option add *Label.background white |
| 41 |
label .l0 -image $src |
| 42 |
label .header0 -text "$width x $height" |
| 43 |
label .footer0 -text "100%" |
| 44 |
. configure -bg white |
| 45 |
|
| 46 |
for { set i 2 } { $i <= 10 } { incr i } { |
| 47 |
set iw [expr $width / $i] |
| 48 |
set ih [expr $height / $i] |
| 49 |
set r [format %6g [expr 100.0 / $i]] |
| 50 |
image create photo r$i -width $iw -height $ih |
| 51 |
winop image resample $src r$i sinc |
| 52 |
label .header$i -text "$iw x $ih" |
| 53 |
label .footer$i -text "$r%" |
| 54 |
label .l$i -image r$i |
| 55 |
table . \ |
| 56 |
0,$i .header$i \ |
| 57 |
1,$i .l$i \ |
| 58 |
2,$i .footer$i |
| 59 |
update |
| 60 |
} |
| 61 |
|
| 62 |
|