1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
\name{gfile}
\alias{gfile}
\alias{gfilebrowse}
\alias{gcalendar}
\title{Dialogs for file and date selection}
\description{
These functions provide dialogs for file selection (files or
directories) and date selections.
}
\usage{
gfile(text = "", type = c("open", "save", "selectdir"), initialfilename = NULL,
filter = list("All files" = list(patterns = c("*")), "R files" =
list(patterns = c("*.R","*.Rdata")),
"text files" = list(mime.types = c("text/plain"))
), multi=FALSE, handler = NULL, action = NULL, ..., toolkit = guiToolkit())
gfilebrowse (text = "Select a file...", type = "open", quote = TRUE,
container = NULL, ..., toolkit = guiToolkit())
gcalendar(text = "", format = "\%Y-\%m-\%d", handler=NULL,
action=NULL, container = NULL, ..., toolkit = guiToolkit())
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{text}{Initial text. For thecalendar, an optional date in a form matching \code{format}}
\item{type}{When selecting a file it can be selected for opening,
for saving or you may want to select a directory.}
\item{initialfilename}{Suggested name for file save}
\item{filter}{Filter for files shown during selection. Can be nested list, as in example or a named character vector with the names a description and value a file extension (no dots) of files endings to match. }
\item{multi}{Logical. Allow selection of multiple files?}
\item{quote}{Is result quoted}
\item{format}{Format of date, default is year-month-day}
\item{handler}{Handler for when file is changed. The component
\code{file} of the first argument contains the file name}
\item{action}{ Passed to handler }
\item{container}{Optional container to attach widget to}
\item{\dots}{Passed to \code{gedit} instance}
\item{toolkit}{Which GUI toolkit to use}
}
\details{
The \code{gfile} dialog is modal, meaning no action can take
place until a selection is made. Whereas the
\code{gfilebrowse} dialog consists of a \code{gedit} instance
to hold a filename and a button to click if the dialog is
desired to fill in this filename.
The \code{gcalendar} widget is similar to the
\code{gfilebrowse} widget.
For both \code{gcalendar} and \code{gfilebrowse} any
\code{...} arguments are passed to \code{gedit}. The
\code{coerce.with} argument can be used to here to quote the
values, or coerce them otherwise such as with
\code{as.Date}. Otherwise, the \code{svalue} method returns
a character string containing the value shown in the
\code{gedit} box.
The \code{svalue<-()} method may be used to set the value for
both \code{gcalendar} and \code{gfilebrowse} .
The return value is the filename selected. A \code{NA} value is
returned if no file is selected.
}
% \value{}
% \references{}
% \author{}
% \note{}
% \seealso{}
\examples{
\dontrun{
## source a file using a handler
sourceFile <- function() gfile("Select a file",type="open", handler =
function(h,...) source(h$file))
## source an R file using fact that dialog is modal
source(gfile(filter=c("R files"="R")))
## apply a generic action to the file
countLines <- function(filename) print(length(readLines(filename)))
chooseFile <- function() gfile("Select a file",type="open",
action="countLines", handler = function(h,...) do.call(h$action,list(h$file)))
}
}
\keyword{interface}
|