Learn R Programming

svGUI (version 1.0.1)

setUI: Set a property in the UI (User Interface), or start an action.

Description

Using setUI() is the preferred way to set a property in a gui object. Similarly, startUI() should be used to indicate that an UI action requiring user input is initiated (say, a modal input or file selection dialog box).

Usage

setUI(..., gui = .GUI)

# S3 method for gui setUI(fun, call, args, res, widgets, status, msg = NULL, ..., gui = .GUI)

startUI(..., gui = .GUI)

# S3 method for gui startUI( fun, call, default, widgets = NULL, status = "busy-modal", msg = "Displaying a modal dialog box", msg.no.ask = "A modal dialog box was by-passed", ..., gui = .GUI )

Arguments

...

Any other property of the GUI, provided as named arguments.

gui

A gui object.

fun

The name of the calling function. Only required if call is provided.

call

The call in the generic as obtained by match.call().

args

A list with checked and/or reworked arguments for a method. The generic can do this work, so that code does not need to be duplicated in all its methods.

res

Any data returned by the GUI (the results).

widgets

The class name of the current widgets implementation.

status

Description of the current GUI status. Could be "ok", "busy", "busy-modal" (a modal dialog box is currently displayed), "by-passed" (the GUI was by-passed because dont_ask() returns TRUE), "error", or any other status indicator suitable for the current state of your GUI.

msg

The message that explains the status. Cannot be provided without status.

default

The default value to return if the UI is by-passed because in non interactive mode, or ask is FALSE.

msg.no.ask

The message that explains the status in case the UI is by-passed.

Methods (by class)

  • gui: Set an UI property for a gui object.

  • gui: Start an UI for a gui object.

See Also

gui_add(), $.gui()

Examples

Run this code
# NOT RUN {
# Imagine you implement a new input box
# In your function, you have this code:
myInput <- function(default = "an answer", gui = .GUI) {

  # Start a GUI action... or by-pass it!
  if (gui$startUI("myInput", call = match.call(), default = default,
    msg = "Displaying an input dialog box",
    msg.no.ask = "An input dialog box was by-passed")) {

    # Here the input dialog box is displayed and R waits for user feedback
    # ... [your code here]
    res <- "some results" # Imagine this is the text typed in the box

    # When the input dialog box is closed, the function should do:
    setUI(res = res, status = NULL)
  }
  invisible(gui)
}
# }

Run the code above in your browser using DataLab