File: gWidgets-dialogs.Rd

package info (click to toggle)
r-cran-gwidgets 0.0-54.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,360 kB
  • sloc: sh: 13; makefile: 2
file content (123 lines) | stat: -rw-r--r-- 4,830 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
\name{gWidgets-dialogs}
\alias{gWidgets-dialogs}
\alias{gmessage}
\alias{galert}
\alias{gconfirm}
\alias{ginput}
\alias{gbasicdialog}

\title{Basic dialog constructors}
\description{
  A dialog is a widget that draws its own window. These dialogs are used
  for simple things -- confirming a choice, gathering a single line of
  input, etc. Dialogs are always modal, meaning they must be closed
  before R can be interacted with again.
}
\usage{
gmessage(message, title="message",
icon = c("info", "warning", "error", "question"),
        parent = NULL,
     handler = NULL, 
    action = NULL, ..., toolkit=guiToolkit()) 

ginput(message, text="", title="Input", icon = c("info", "warning",
 "error", "question"), parent=NULL, 
 handler = NULL, action = NULL,..., toolkit=guiToolkit())

gconfirm(message, title="Confirm", icon = c("info", "warning", "error",
 "question"), parent=NULL,
 handler = NULL, action = NULL, ..., toolkit=guiToolkit())

gbasicdialog(title = "Dialog", widget, parent=NULL, do.buttons=TRUE, 
handler = NULL, action=NULL,  ..., toolkit=guiToolkit())

galert(message, title = "message", delay=3, parent=NULL, ..., toolkit=guiToolkit())
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{message}{Message shown for widget}
  \item{title}{Title of window}
  \item{icon}{Which icon to show}
  \item{text}{default value for ginput text}
  \item{widget}{Widget to place in basic dialog. If missing, dialog returns a container.}
  \item{parent}{A gwindow() instance. If specified, dialog will be
    located in relation to this}
  \item{do.buttons}{For \code{gbasicdialog} -- when no \code{widget}
    argument is passed in -- this can be used to suppress the addition of
    Ok and Cancel buttons. If suppressed, the dialog can be closed by the
    window manager or programattically through the \code{dispose} method.}
  \item{handler}{Handler called on OK selection.}
  \item{action}{Value passed to handler}
  \item{delay}{For galert, how long the transient message will appear}
  \item{\dots}{Ignored}
  \item{toolkit}{Toolkit to use for GUI}
}
\details{
  These basic dialogs do slightly different things.

  The \code{gmessage} dialog shows a message with an icon and a dismiss
  button. This dialog returns \code{TRUE} or \code{FALSE} as
  appropriate. 

  The \code{gconfirm} dialog shows a message with an icon and an OK
  button and a dismiss button. A handler may be attached to the OK
  button selection. This dialog returns \code{TRUE} or \code{FALSE} as
  appropriate. 

  The \code{ginput} dialog adds an edit box for gathering user
  information. The \code{text} argument sets the default value. This is
  then passed to the handler via the component \code{input} of the first
  argument of the handler. This dialog returns the value of the string
  if OK is clicked, otherwise \code{NA}.

  The \code{gbasicdialog} widget wraps a dialog (with buttons) around
   a widget. For \pkg{gWidgetsRGtk2} and \pkg{gWidgetsQt} the widget may be specified throuh the
   \code{widget} argument of the constructor. The constructor produces
   a modal dialog, hence no methods are defined. The return value is a
   logical indicating which button was clicked.

  More portably (hence encouraged), if the \code{widget} argument is NULL, then the
  constructor produces a container. This container becomes modal after a
  call to \code{visible(..., set=TRUE)} (not the assignment version
  though). Again the return value is a logical.  This too creates a
  modal dialog. The handler specified to the constructor is called when
  OK is clicked and \code{TRUE} is returned. The value of \code{FALSE}
  is returned on cancel, and \code{NA} otherwise.

  The buttons may be suppressed by setting the argument
  \code{do.buttons=FALSE}. The
  dialog then may be closed by calling the \code{dispose} method
  within a callback.


  These dialogs are modal. This means that the R session freezes until
  the dialog is dismissed. This may be confusing to users if the window
  should appear below a currently drawn window.

  The \code{galert} dialog is non-modal and does not grab the
  focus. Like \code{gmessage} it shows a message but unlike it, only
  for a short period of time and is unobtrusive.

}
% \value{}
% \references{}
% \author{}
% \note{}
% \seealso{}
\examples{
\dontrun{
   gmessage("Hi there")
   gconfirm("Are we having fun?", handler = function(h,...)
   print("Yes"))

   ginput("Enter your name", icon="question", handler = function(h,...) cat("Hi",h$input,"\n"))

   ## gbasicdialog
   w <- gbasicdialog(title="Select a state", handler = function(h,...) 
      print(svalue(tbl)))
   tbl <- gtable(data.frame(states = rownames(state.x77)), expand=TRUE, container = w)
   visible(w, set=TRUE) ## show dialog

}
}
\keyword{interface}% at least one, from doc/KEYWORDS