Description Usage Arguments Details Value Author(s) References See Also Examples
All the primary widgets such as button, text box, and so on are objects of basicPW class. The functions are constructors of primary widgets that are subjects of basicPW class with behaviors specific to primary widgets.
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 | button(wName, wEnv, wValue = "", wWidth = 12, wHeight = 0, wFuns = list(),
wNotify = list(), wPreFun = function(x) x, wPostFun = function(x) x,
wView = new("widgetView") )
entryBox(wName, wEnv, wValue = "", wWidth = 50, wHeight = 0, wFuns = list(),
wNotify = list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
textBox(wName, wEnv, wValue = "", wWidth = 25, wHeight = 12, wFuns = list(),
wNotify = list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
listBox(wName, wEnv, wValue = "", wWidth = 25, wHeight = 10, wFuns = list(),
wNotify = list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
checkButton(wName, wEnv, wValue, wWidth = 50, wFuns = list(), wNotify =
list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
radioButton(wName, wEnv, wValue, wWidth = 50, wFuns = list(), wNotify =
list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
label(wName, wEnv, wValue = "", wWidth = 0, wHeight = 0, wFuns = list(),
wNotify = list(), wPreFun = function (x) x, wPostFun = function(x) x,
wView = new("widgetView"))
widget(wTitle, pWidgets, funs = list(), preFun = function()
print("Hello"), postFun = function() print("Bye"), env, defaultNames =c(
"Finish", "Cancel"))
widgetView(WVTitle, vName, widgetids = list(), theWidget = new("widget"),
winid)
|
wName |
|
vName |
|
wEnv |
|
env |
|
wValue |
|
wWidth |
|
wHeight |
|
wFuns |
|
funs |
|
wNotify |
|
wPreFun |
|
preFun |
|
wPostFun |
|
postFun |
|
wTitle |
|
pWidgets |
|
WVTitle |
|
widgetids |
|
theWidget |
|
wView |
|
winid |
|
defaultNames |
|
button
constructs a button widget object.
button
constructs an entry box widget object.
textBox
constructs a text box widget object.
listBox
constructs a list box widget object. Value for
a listbox object should be a named vector with names being the content
to be shown in the list box and values being TRUE (default value) or
FALSE.
checkButton
constructs a group of check box widget
objects. Value for check button objects should be a named vector
with names being the content to be shown in the list box and values
being TRUE (checked) or FALSE (not checked).
radioButton
constructs a group of radio button widget
objects. Value for radio button objects should be a named vector
with names being the content to be shown in the list box and values
being TRUE (default) or FALSE.
label
constructs a text label widget object with the
value displayed as the text.
widget
constructs a widget object to render the primary
widgets.
widgetView
constructs a widgetView object. This class is
for internal use by class widget-class
. Users trying to
create GUI type widget do not need to use this class.
Each constructor returns a tkwin object for the primary widget object.
Jianhua Zhang
R tcltk
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 | # Create an R environment to store the values of primary widgets
PWEnv <- new.env(hash = TRUE, parent = parent.frame(1))
# Create a label
label1 <- label(wName = "label1", wValue = "File Name: ", wEnv = PWEnv)
# Create an entry box with "Feed me using brows" as the default value
entry1 <- entryBox(wName = "entry1", wValue = "Feed me using browse",
wEnv = PWEnv)
# Create a button that will call the function browse2Entry1 when
# pressed.
browse2Entry1 <- function(){
tempValue <- tclvalue(tkgetOpenFile())
temp <- get(wName(entry1), env = PWEnv)
wValue(temp) <- paste(tempValue, sep = "", collapse = ";")
assign(wName(entry1), temp, env = PWEnv)
}
button1 <- button(wName = "button1", wValue = "Browse",
wFuns = list(command = browse2Entry1), wEnv = PWEnv)
# Create a list box with "Option1", "Option2", and "Option3" as the
# content and "Option1" selected
list1 <- listBox(wName = "list1", wValue = c(Option1 = TRUE, Option2 = FALSE,
Option3 = FALSE), wEnv = PWEnv)
# Create a text box with "Feed me something" displayed
text1 <- textBox(wName = "text1", wValue = "Feed me something",
wEnv = PWEnv)
# Create a set of radio buttons with "radio1" as the default
label2 <- label(wName = "label2", wValue = "Select one: ", wEnv = PWEnv)
radios1 <- radioButton(wName = "radios1", wValue = c(radio1 = TRUE,
radio2 = FALSE, radio3 = FALSE), wEnv = PWEnv)
# Create a set of check boxes with "check1" selected and "check2" and
# "check3" not selected
label3 <- label(wName = "label3", wValue = "Select one to many: ",
wEnv = PWEnv)
checks1 <- checkButton(wName = "checks1", wValue = c(check1 = TRUE,
check22 = FALSE, check3 = FALSE), wEnv = PWEnv)
# Please not that the name of the primary widget object (e.g. checks1)
# should be the same as the value of the name slot of the object
# (e. g. name = "checks1")
# Render the widgets
pWidgets <- list(topRow = list(label1 = label1, entry1 = entry1,
button1 = button1), textRow = list(list1 = list1,
text1 = text1), radGroup = list(label2 = label2,
radios1 = radios1), chkGroup = list(label3 = label3,
checks1 = checks1))
## Not run:
## These cannot be run by examples() but should be OK when pasted
## into an interactive R session with the widgetTools package loaded
aWidget <- widget(wTitle = "A test widget", pWidgets, funs = list(),
preFun = function() print("Hello"),
postFun = function() print("Bye"), env = PWEnv)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.