Type: | Package |
Version: | 1.0.0 |
Date: | 2022-05-10 |
Title: | 'SciViews' - Standard Dialog Boxes using Tcl/Tk |
Description: | Reimplementation of the 'svDialogs' dialog boxes in Tcl/Tk. |
Maintainer: | Philippe Grosjean <phgrosjean@sciviews.org> |
Depends: | R (≥ 2.6.0), svDialogs (≥ 1.0.0), tcltk |
Imports: | svGUI (≥ 1.0.0), utils, grDevices |
Suggests: | spelling, covr, knitr, rmarkdown |
License: | GPL-2 |
URL: | https://github.com/SciViews/svDialogstcltk, https://www.sciviews.org/svDialogstcltk/ |
BugReports: | https://github.com/SciViews/svDialogstcltk/issues |
RoxygenNote: | 7.1.1 |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
Language: | en-US |
NeedsCompilation: | no |
Packaged: | 2022-05-10 16:18:04 UTC; phgrosjean |
Author: | Philippe Grosjean |
Repository: | CRAN |
Date/Publication: | 2022-05-10 16:50:02 UTC |
svDialogstcltk: 'SciViews' - Standard Dialog Boxes using Tcl/Tk
Description
Reimplementation of the 'svDialogs' dialog boxes in Tcl/Tk.
Details
Implementation of Tcl/Tk dialog boxes for svDialogs. When the package is
loaded, it inserts a new tcltkGUI
dependency in the .GUI
object (if it is
not defined yet). That way, every call to .GUI
dispatches first to the
current Tcl/Tk implementation of the dialog boxes. For your own, separate GUI
(say called myGUI
), you have to create the binding by yourself by calling
svGUI::gui_widgets(myGUI) <- "tcltkGUI"
.
Important functions
-
dlg_message()
display a message box, -
dlg_input()
prompt for textual input, -
dlg_list()
select one or more items in a list, -
dlg_open()
open one or more existing file(s), -
dlg_save()
prompt for a file to save to (and ask confirmation if the file already exists), -
dlg_dir()
select a directory,
Author(s)
Maintainer: Philippe Grosjean phgrosjean@sciviews.org (ORCID)
See Also
Useful links:
Report bugs at https://github.com/SciViews/svDialogstcltk/issues
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
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 |
default |
The default value in the text box. Single string or |
... |
Not used yet. |
gui |
The 'gui' object concerned by this dialog box. |
Value
The string the user wrote in the dialog box.
See Also
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 |
multiple |
Is it a multiple selection dialog box? |
title |
The title of the dialog box, or |
... |
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
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: |
... |
Not used yet. |
gui |
The 'gui' object concerned by this dialog box. |
Value
The button pressed by the user.
See Also
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 |
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 |
... |
Not used yet. |
gui |
The 'gui' object concerned by this dialog box. |
Value
The path to the file to open.
See Also
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 |
title |
A title to display on top of the dialog box. |
filters |
A specification of file filters as a |
... |
Not used yet. |
gui |
The 'gui' object concerned by this dialog box. |
Value
The path to the file to save to.
See Also
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)