| Title: | 'SciViews::R' - Standard Dialog Boxes using Tcl/Tk |
|---|---|
| Description: | Reimplementation of the 'svDialogs' dialog boxes in Tcl/Tk. |
| Authors: | Philippe Grosjean [aut, cre] (ORCID: <https://orcid.org/0000-0002-2694-9471>) |
| Maintainer: | Philippe Grosjean <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.1 |
| Built: | 2026-06-04 08:24:27 UTC |
| Source: | https://github.com/SciViews/svDialogstcltk |
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".
svDialogs::dlg_message() display a message box,
svDialogs::dlg_input() prompt for textual input,
svDialogs::dlg_list() select one or more items in a list,
svDialogs::dlg_open() open one or more existing file(s),
svDialogs::dlg_save() prompt for a file to save to (and ask confirmation if the file
already exists),
svDialogs::dlg_dir() select a directory,
Maintainer: Philippe Grosjean [email protected] (ORCID)
Useful links:
Report bugs at https://github.com/SciViews/svDialogstcltk/issues
Select an existing directory, or create a new one.
## S3 method for class 'tcltkGUI' dlg_dir(default = getwd(), title = "Choose a directory", ..., gui = .GUI)## S3 method for class 'tcltkGUI' dlg_dir(default = getwd(), title = "Choose a directory", ..., gui = .GUI)
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. |
The path to the selected folder.
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)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)
Prompt for some data in a modal dialog box.
## S3 method for class 'tcltkGUI' dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)## S3 method for class 'tcltkGUI' dlg_input(message = "Enter a value", default = "", ..., gui = .GUI)
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. |
The string the user wrote in the dialog box.
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)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
## S3 method for class 'tcltkGUI' dlg_list( choices, preselect = NULL, multiple = FALSE, title = NULL, ..., gui = .GUI )## S3 method for class 'tcltkGUI' dlg_list( choices, preselect = NULL, multiple = FALSE, title = NULL, ..., gui = .GUI )
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. |
A character vector with the items that were selected by the user.
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)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
## S3 method for class 'tcltkGUI' dlg_message( message, type = c("ok", "okcancel", "yesno", "yesnocancel"), ..., gui = .GUI )## S3 method for class 'tcltkGUI' dlg_message( message, type = c("ok", "okcancel", "yesno", "yesnocancel"), ..., gui = .GUI )
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. |
The button pressed by the user.
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)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
## S3 method for class 'tcltkGUI' dlg_open( default = "", title = if (multiple) "Select files" else "Select file", multiple = FALSE, filters = dlg_filters["All", ], ..., gui = .GUI )## S3 method for class 'tcltkGUI' dlg_open( default = "", title = if (multiple) "Select files" else "Select file", multiple = FALSE, filters = dlg_filters["All", ], ..., gui = .GUI )
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. |
The path to the file to open.
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)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
## S3 method for class 'tcltkGUI' dlg_save( default = "untitled", title = "Save file as", filters = dlg_filters["All", ], ..., gui = .GUI )## S3 method for class 'tcltkGUI' dlg_save( default = "untitled", title = "Save file as", filters = dlg_filters["All", ], ..., gui = .GUI )
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. |
The path to the file to save to.
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)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)