source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/lib/linux/tk8.4/demos/filebox.tcl @ 37

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

Added original make3d

File size: 2.1 KB
Line 
1# filebox.tcl --
2#
3# This demonstration script prompts the user to select a file.
4#
5# RCS: @(#) $Id: filebox.tcl,v 1.3 2001/06/14 10:56:58 dkf Exp $
6
7if {![info exists widgetDemo]} {
8    error "This script should be run from the \"widget\" demo."
9}
10
11set w .filebox
12catch {destroy $w}
13toplevel $w
14wm title $w "File Selection Dialogs"
15wm iconname $w "filebox"
16positionWindow $w
17
18label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog."
19pack $w.msg -side top
20
21frame $w.buttons
22pack $w.buttons -side bottom -fill x -pady 2m
23button $w.buttons.dismiss -text Dismiss -command "destroy $w"
24button $w.buttons.code -text "See Code" -command "showCode $w"
25pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
26
27foreach i {open save} {
28    set f [frame $w.$i]
29    label $f.lab -text "Select a file to $i: " -anchor e
30    entry $f.ent -width 20
31    button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i"
32    pack $f.lab -side left
33    pack $f.ent -side left -expand yes -fill x
34    pack $f.but -side left
35    pack $f -fill x -padx 1c -pady 3
36}
37
38if {![string compare $tcl_platform(platform) unix]} {
39    checkbutton $w.strict -text "Use Motif Style Dialog" \
40        -variable tk_strictMotif -onvalue 1 -offvalue 0
41    pack $w.strict -anchor c
42}
43
44proc fileDialog {w ent operation} {
45    #   Type names              Extension(s)    Mac File Type(s)
46    #
47    #---------------------------------------------------------
48    set types {
49        {"Text files"           {.txt .doc}     }
50        {"Text files"           {}              TEXT}
51        {"Tcl Scripts"          {.tcl}          TEXT}
52        {"C Source Files"       {.c .h}         }
53        {"All Source Files"     {.tcl .c .h}    }
54        {"Image Files"          {.gif}          }
55        {"Image Files"          {.jpeg .jpg}    }
56        {"Image Files"          ""              {GIFF JPEG}}
57        {"All files"            *}
58    }
59    if {$operation == "open"} {
60        set file [tk_getOpenFile -filetypes $types -parent $w]
61    } else {
62        set file [tk_getSaveFile -filetypes $types -parent $w \
63            -initialfile Untitled -defaultextension .txt]
64    }
65    if {[string compare $file ""]} {
66        $ent delete 0 end
67        $ent insert 0 $file
68        $ent xview end
69    }
70}
Note: See TracBrowser for help on using the repository browser.