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-08-27 02:50:45 UTC |
Source: | https://github.com/SciViews/svDialogstcltk |
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)