source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/vrip/lib/tk/demos/image2.tcl @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.6 KB
Line 
1# image2.tcl --
2#
3# This demonstration script creates a simple collection of widgets
4# that allow you to select and view images in a Tk label.
5#
6# RCS: @(#) $Id: image2.tcl,v 1.2 1998/09/14 18:23:29 stanton Exp $
7
8if {![info exists widgetDemo]} {
9    error "This script should be run from the \"widget\" demo."
10}
11
12# loadDir --
13# This procedure reloads the directory listbox from the directory
14# named in the demo's entry.
15#
16# Arguments:
17# w -                   Name of the toplevel window of the demo.
18
19proc loadDir w {
20    global dirName
21
22    $w.f.list delete 0 end
23    foreach i [lsort [glob [file join $dirName *]]] {
24        $w.f.list insert end [file tail $i]
25    }
26}
27
28# loadImage --
29# Given the name of the toplevel window of the demo and the mouse
30# position, extracts the directory entry under the mouse and loads
31# that file into a photo image for display.
32#
33# Arguments:
34# w -                   Name of the toplevel window of the demo.
35# x, y-                 Mouse position within the listbox.
36
37proc loadImage {w x y} {
38    global dirName
39
40    set file [file join $dirName [$w.f.list get @$x,$y]]
41    image2a configure -file $file
42}
43
44set w .image2
45catch {destroy $w}
46toplevel $w
47wm title $w "Image Demonstration #2"
48wm iconname $w "Image2"
49positionWindow $w
50
51label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration allows you to view images using a Tk \"photo\" image.  First type a directory name in the listbox, then type Return to load the directory into the listbox.  Then double-click on a file name in the listbox to see that image."
52pack $w.msg -side top
53
54frame $w.buttons
55pack $w.buttons -side bottom -fill x -pady 2m
56button $w.buttons.dismiss -text Dismiss -command "destroy $w"
57button $w.buttons.code -text "See Code" -command "showCode $w"
58pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
59
60label $w.dirLabel -text "Directory:"
61set dirName [file join $tk_library demos images]
62entry $w.dirName -width 30 -textvariable dirName
63bind $w.dirName <Return> "loadDir $w"
64frame $w.spacer1 -height 3m -width 20
65label $w.fileLabel -text "File:"
66frame $w.f
67pack $w.dirLabel $w.dirName $w.spacer1 $w.fileLabel $w.f -side top -anchor w
68
69listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set"
70scrollbar $w.f.scroll -command "$w.f.list yview"
71pack $w.f.list $w.f.scroll -side left -fill y -expand 1
72$w.f.list insert 0 earth.gif earthris.gif teapot.ppm
73bind $w.f.list <Double-1> "loadImage $w %x %y"
74
75catch {image delete image2a}
76image create photo image2a
77frame $w.spacer2 -height 3m -width 20
78label $w.imageLabel -text "Image:"
79label $w.image -image image2a
80pack $w.spacer2 $w.imageLabel $w.image -side top -anchor w
Note: See TracBrowser for help on using the repository browser.