gfile                package:gWidgets                R Documentation

_D_i_a_l_o_g_s _f_o_r _f_i_l_e _a_n_d _d_a_t_e _s_e_l_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     These functions provide dialogs for file selection (files or
     directories) and date selections.

_U_s_a_g_e:

     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"))
             ), 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()) 

_A_r_g_u_m_e_n_t_s:

    text: Initial text

    type: When selecting a file it can be selected for opening, for
          saving or you may want to select a directory.

initialfilename: Suggested name for file save

  filter: Filter for files shown during selection 

   quote: Is result quoted

  format: Format of date

 handler: Handler for when file is changed. The component 'file' of the
          first argument contains the file name

  action: Passed to handler 

container: Optional container to attach widget to

     ...: Passed to 'gedit' instance

 toolkit: Which GUI toolkit to use

_D_e_t_a_i_l_s:

     The 'gfile' dialog is modal, meaning no action can take place
     until a selection is made. Whereas the 'gfilebrowse' dialog
     consists of a 'gedit' instance to hold a filename and a button to
     click if the dialog is desired to fill in this filename.

     The 'gcalendar' widget is similar to the 'gfilebrowse' widget.

     For both 'gcalendar' and 'gfilebrowse' any '...' arguments are
     passed to 'gedit'. The 'coerce.with' argument can be used to here
     to quote the values, or coerce them otherwise such as with
     'as.Date'. Otherwise, the 'svalue' method returns a character
     string containing the value shown in the 'gedit' box.

     The 'svalue<-()' method may be used to set the value for both
     'gcalendar' and 'gfilebrowse' .

     The return value is the filename selected. A 'NA' value is
     returned if no file is selected.

_E_x_a_m_p_l_e_s:

     ## Not run: 
     ## source a file using a handler
     sourceFile = function() gfile("Select a file",type="open", handler =
     function(h,...) source(h$file))

     ## source a file using fact that dialog is modal
     source(gfile())

     ## 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)))
     ## End(Not run)

