OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [doc/] [getOpenFile.n] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1996 Sun Microsystems, Inc.
3
'\"
4
'\" See the file "license.terms" for information on usage and redistribution
5
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
6
'\"
7
'\" RCS: @(#) $Id: getOpenFile.n,v 1.1.1.1 2002-01-16 10:25:49 markom Exp $
8
'\"
9
.so man.macros
10
.TH tk_getOpenFile n 4.2 Tk "Tk Built-In Commands"
11
.BS
12
'\" Note:  do not modify the .SH NAME line immediately below!
13
.SH NAME
14
tk_getOpenFile, tk_getSaveFile \- pop up a dialog box for the user to select a file to open or save.
15
.PP
16
.PP
17
.SH SYNOPSIS
18
\fBtk_getOpenFile \fR?\fIoption value ...\fR?
19
.br
20
\fBtk_getSaveFile \fR?\fIoption value ...\fR?
21
.BE
22
 
23
.SH DESCRIPTION
24
.PP
25
The procedures \fBtk_getOpenFile\fR and \fBtk_getSaveFile\fR pop up a
26
dialog box for the user to select a file to open or save. The
27
\fBtk_getOpenFile\fR command is usually associated with the \fBOpen\fR
28
command in the \fBFile\fR menu. Its purpose is for the user to select an
29
existing file \fIonly\fR. If the user enters an non-existent file, the
30
dialog box gives the user an error prompt and requires the user to give
31
an alternative selection. If an application allows the user to create
32
new files, it should do so by providing a separate \fBNew\fR menu command.
33
.PP
34
The \fBtk_getSaveFile\fR command is usually associated with the \fBSave
35
as\fR command in the \fBFile\fR menu. If the user enters a file that
36
already exists, the dialog box prompts the user for confirmation
37
whether the existing file should be overwritten or not.
38
.PP
39
The following \fIoption\-value\fR pairs are possible as command line
40
arguments to these two commands:
41
.TP
42
\fB\-defaultextension\fR \fIextension\fR
43
Specifies a string that will be appended to the filename if the user
44
enters a filename without an extension. The defaut value is the empty
45
string, which means no extension will be appended to the filename in
46
any case. This option is ignored on the Macintosh platform, which
47
does not require extensions to filenames.
48
.TP
49
\fB\-filetypes\fR \fIfilePatternList\fR
50
If a \fBFile types\fR listbox exists in the file dialog on the particular
51
platform, this option gives the \fIfiletype\fRs in this listbox. When
52
the user choose a filetype in the listbox, only the files of that type
53
are listed. If this option is unspecified, or if it is set to the
54
empty list, or if the \fBFile types\fR listbox is not supported by the
55
particular platform then all files are listed regardless of their
56
types. See the section SPECIFYING FILE PATTERNS below for a
57
discussion on the contents of \fIfilePatternList\fR.
58
.TP
59
\fB\-initialdir\fR \fIdirectory\fR
60
Specifies that the files in \fIdirectory\fR should be displayed
61
when the dialog pops up. If this parameter is not specified, then
62
the files in the current working directory are displayed. If the
63
parameter specifies a relative path, the return value will convert the
64
relative path to an absolute path.  This option may not always work on
65
the Macintosh.  This is not a bug. Rather, the \fIGeneral Controls\fR
66
control panel on the Mac allows the end user to override the
67
application default directory.
68
.TP
69
\fB\-initialfile\fR \fIfilename\fR
70
Specifies a filename to be displayed in the dialog when it pops
71
up. This option is ignored by the \fBtk_getOpenFile\fR command.
72
.TP
73
\fB\-parent\fR \fIwindow\fR
74
Makes \fIwindow\fR the logical parent of the file dialog. The file
75
dialog is displayed on top of its parent window.
76
.TP
77
\fB\-title\fR \fItitleString\fR
78
Specifies a string to display as the title of the dialog box. If this
79
option is not specified, then a default title is displayed. This
80
option is ignored on the Macintosh platform.
81
.PP
82
If the user selects a file, both \fBtk_getOpenFile\fR and
83
\fBtk_getSaveFile\fR return the full pathname of this file. If the
84
user cancels the operation, both commands return the empty string.
85
.SH "SPECIFYING FILE PATTERNS"
86
 
87
The \fIfilePatternList\fR value given by the \fB\-filetypes\fR option
88
is a list of file patterns. Each file pattern is a list of the
89
form
90
.CS
91
\fItypeName\fR {\fIextension\fR ?\fIextension ...\fR?} ?{\fImacType\fR ?\fImacType ...\fR?}?
92
.CE
93
\fItypeName\fR is the name of the file type described by this
94
file pattern and is the text string that appears in the \fBFile types\fR
95
listbox. \fIextension\fR is a file extension for this file pattern.
96
\fImacType\fR is a four-character Macintosh file type. The list of
97
\fImacType\fRs is optional and may be omitted for applications that do
98
not need to execute on the Macintosh platform.
99
.PP
100
Several file patterns may have the same \fItypeName,\fR in which case
101
they refer to the same file type and share the same entry in the
102
listbox. When the user selects an entry in the listbox, all the files
103
that match at least one of the file patterns corresponding
104
to that entry are listed. Usually, each file pattern corresponds to a
105
distinct type of file. The use of more than one file patterns for one
106
type of file is necessary on the Macintosh platform only.
107
.PP
108
On the Macintosh platform, a file matches a file pattern if its
109
name matches at least one of the \fIextension\fR(s) AND it
110
belongs to at least one of the \fImacType\fR(s) of the
111
file pattern. For example, the \fBC Source Files\fR file pattern in the
112
sample code matches with files that have a \fB\.c\fR extension AND
113
belong to the \fImacType\fR \fBTEXT\fR. To use the OR rule instead,
114
you can use two file patterns, one with the \fIextensions\fR only and
115
the other with the \fImacType\fR only. The \fBGIF Files\fR file type
116
in the sample code matches files that EITHER have a \fB\.gif\fR
117
extension OR belong to the \fImacType\fR \fBGIFF\fR.
118
.PP
119
On the Unix and Windows platforms, a file matches a file pattern
120
if its name matches at at least one of the \fIextension\fR(s) of
121
the file pattern. The \fImacType\fRs are ignored.
122
.SH "SPECIFYING EXTENSIONS"
123
.PP
124
On the Unix and Macintosh platforms, extensions are matched using
125
glob-style pattern matching. On the Windows platforms, extensions are
126
matched by the underlying operating system. The types of possible
127
extensions are: (1) the special extension * matches any
128
file; (2) the special extension "" matches any files that
129
do not have an extension (i.e., the filename contains no full stop
130
character); (3) any character string that does not contain any wild
131
card characters (* and ?).
132
.PP
133
Due to the different pattern matching rules on the various platforms,
134
to ensure portability, wild card characters are not allowed in the
135
extensions, except as in the special extension *. Extensions
136
without a full stop character (e.g, ~) are allowed but may not
137
work on all platforms.
138
 
139
.SH EXAMPLE
140
.CS
141
set types {
142
    {{Text Files}       {.txt}        }
143
    {{TCL Scripts}      {.tcl}        }
144
    {{C Source Files}   {.c}      TEXT}
145
    {{GIF Files}        {.gif}        }
146
    {{GIF Files}        {}        GIFF}
147
    {{All Files}        *             }
148
}
149
set filename [tk_getOpenFile -filetypes $types]
150
 
151
if {$filename != ""} {
152
    # Open the file ...
153
}
154
.CE
155
 
156
.SH KEYWORDS
157
file selection dialog

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.