tk.utils: Tk interface utilities

tk.utilsR Documentation

Tk interface utilities

Description

These functions are components used to build interactive interfaces.

tk.file is a wrapper to tcltk functions tkgetOpenFile and tkgetOpenFile with several enhancements.

tk.files proposes to build and order a file list from multiple calls to tk.file.

tk.folder is a wrapper to tcltk function tkchooseDirectory with small enhancements.

handle is a wrapper to withRestarts, which allows to catch errors, warnings and messages while executing an R expression and handle them with custom functions.

Usage

  tk.file(title = "Choose a file", typeNames = "All files", typeExt = "*",
    multiple = FALSE, mandatory = TRUE, type = c("open", "save"), initialdir = NULL,
    parent = NULL)
  tk.files(preselection = character(0), multiple = TRUE, parent = NULL, ...)
  tk.folder(title = "Choose a directory", mustexist = TRUE, mandatory = TRUE)
  handle(expr, messageHandler, warningHandler, errorHandler)

Arguments

title

Single character value, the displayed name of the summoned window.

typeNames

Character vector defining the displayed names of the filtered file extensions. Parallel to typeExt.

typeExt

Character vector defining the filtered file extensions (use "*" as wildcard). Parallel to typeNames.

multiple

Single logical value, whether to allow multiple file selection or not.

mandatory

Single logical value, whether to throw an error if no file is selected or not.

type

Single character value defining the label of the button.

initialdir

Single character value, the initially selected directory when the window is summoned. NULL corresponds to the last directory browsed via one of these functions.

parent

A Tcl-Tk object to consider as the parent of the new frame.

preselection

Character vector, the files already selected when the window is summoned.

...

Further arguments to be passed to tk.file.

mustexist

Single logical value, whether to throw an error if a non-existing directory is selected or not.

expr

An R expression in which errors, warnings and messages are to be caught. Use {} to monitor a multi-line R code.

messageHandler

A function taking as single argument the condition object caught. If missing, messages will pass through.

warningHandler

A function taking as single argument the condition object caught. If missing, warnings will pass through.

errorHandler

A function taking as single argument the condition object caught. If missing, errors will pass through.

Value

tk.file, tk.files and tk.folder return the selection as a character vector, possibly empty.

handle returns nothing.

Author(s)

Sylvain Mareschal

See Also

tk.browse, tk.convert, tk.tracks


Rgb documentation built on Aug. 18, 2023, 5:05 p.m.