Package 'svDialogstcltk'

Title: 'SciViews' - Standard Dialog Boxes using Tcl/Tk
Description: Reimplementation of the 'svDialogs' dialog boxes in Tcl/Tk.
Authors: Philippe Grosjean [aut, cre]
Maintainer: Philippe Grosjean <[email protected]>
License: GPL-2
Version: 1.0.0
Built: 2024-12-25 02:39:56 UTC
Source: https://github.com/SciViews/svDialogstcltk

Help Index


A Tcl/Tk version of the svDialogs directory selection dialog box

Description

Select an existing directory, or create a new one.

Usage

## S3 method for class 'tcltkGUI'
dlg_dir(default = getwd(), title = "Choose a directory", ..., gui = .GUI)

Arguments

default

The path to the default directory that is proposed (e.g., current working directory).

title

A title to display on top of the dialog box.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

The path to the selected folder.

See Also

svDialogs::dlg_dir()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# A quick default directory changer
setwd(dlg_dir(default = getwd())$res)

## End(Not run)

A Tcl/Tk version of the svDialogs input a string or value dialog box

Description

Prompt for some data in a modal dialog box.

Usage

## S3 method for class 'tcltkGUI'
dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)

Arguments

message

The message to display in the dialog box. Use ⁠\\n⁠ for line break, or provide a vector of character strings, one for each line.

default

The default value in the text box. Single string or NULL.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

The string the user wrote in the dialog box.

See Also

svDialogs::dlg_input()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# Ask something...
user <- dlg_input("Who are you?", Sys.info()["user"])$res
if (!length(user)) {# The user clicked the 'cancel' button
  cat("OK, you prefer to stay anonymous!\n")
} else {
  cat("Hello", user, "\n")
}

## End(Not run)

A Tcl/Tk version of the svDialogs list selection dialog box

Description

A Tcl/Tk version of the svDialogs list selection dialog box

Usage

## S3 method for class 'tcltkGUI'
dlg_list(
  choices,
  preselect = NULL,
  multiple = FALSE,
  title = NULL,
  ...,
  gui = .GUI
)

Arguments

choices

The list of items. It is coerced to character strings.

preselect

A list of preselections, or NULL (then, the first element is selected in the list). Preselections not in choices are tolerated (but they are ignored without warning or error).

multiple

Is it a multiple selection dialog box?

title

The title of the dialog box, or NULL to use a default title instead.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

A character vector with the items that were selected by the user.

See Also

svDialogs::dlg_list()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# Select one or several months
res <- dlg_list(month.name, multiple = TRUE)$res
if (!length(res)) {
  cat("You cancelled the choice\n")
} else {
  cat("You selected:\n")
  print(res)
}

## End(Not run)

A Tcl/Tk version of the svDialogs message box

Description

A Tcl/Tk version of the svDialogs message box

Usage

## S3 method for class 'tcltkGUI'
dlg_message(
  message,
  type = c("ok", "okcancel", "yesno", "yesnocancel"),
  ...,
  gui = .GUI
)

Arguments

message

The message to display in the dialog box.

type

The type of dialog box: 'ok', 'okcancel', 'yesno' or 'yesnocancel'.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

The button pressed by the user.

See Also

svDialogs::dlg_message()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# A simple information box
dlg_message("Hello world!")$res

# Ask to continue
dlg_message(c("This is a long task!", "Continue?"), "okcancel")$res

# Ask a question
dlg_message("Do you like apples?", "yesno")$res

# Idem, but one can interrupt too
res <- dlg_message("Do you like oranges?", "yesnocancel")$res
if (res == "cancel")
  cat("Ah, ah! You refuse to answer!\n")

## End(Not run)

A Tcl/Tk version of the svDialogs file open dialog box

Description

A Tcl/Tk version of the svDialogs file open dialog box

Usage

## S3 method for class 'tcltkGUI'
dlg_open(
  default = "",
  title = if (multiple) "Select files" else "Select file",
  multiple = FALSE,
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

Arguments

default

The default file to start with (use ⁠/dir/*⁠ or ⁠/dir/*.*⁠ to start in a given directory).

title

A title to display on top of the dialog box.

multiple

Is a multiple selection of files allowed?

filters

A specification of file filters as a nx2 matrix, or a character string with even number of items. First items is the label, second one is the filter. See dlg_filters for examples. This is currently ignored on MacOS and RStudio, since such kind of filter is defined differently there.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

The path to the file to open.

See Also

svDialogs::dlg_open()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# Choose one R file
dlg_open(title = "Select one R file", filters = dlg_filters[c("R", "All"), ])$res
# Choose several files
dlg_open(multiple = TRUE)$res

## End(Not run)

A Tcl/Tk version of the svDialogs file save dialog box

Description

A Tcl/Tk version of the svDialogs file save dialog box

Usage

## S3 method for class 'tcltkGUI'
dlg_save(
  default = "untitled",
  title = "Save file as",
  filters = dlg_filters["All", ],
  ...,
  gui = .GUI
)

Arguments

default

The default file to start with (use ⁠/dir/*⁠ or ⁠/dir/*.*⁠ to start in a given directory, but without predefined name).

title

A title to display on top of the dialog box.

filters

A specification of file filters as a nx2 matrix, or a character string with even number of items. First items is the label, second one is the filter. See dlg_filters for examples. This is currently ignored on MacOS, since such kind of filter is defined differently there.

...

Not used yet.

gui

The 'gui' object concerned by this dialog box.

Value

The path to the file to save to.

See Also

svDialogs::dlg_save()

Examples

library(svDialogstcltk) # Tcl/Tk dialog boxes are now used by default
## Not run: 
# Choose one R filename to save some R script into it
dlg_save(title = "Save R script to", filters = dlg_filters[c("R", "All"), ])$res

## End(Not run)