Title: | R based tk widgets |
---|---|
Description: | Widgets to provide user interfaces. tcltk should have been installed for the widgets to run. |
Authors: | J. Zhang <[email protected]> |
Maintainer: | J. Zhang <[email protected]> |
License: | Artistic-2.0 |
Version: | 1.85.0 |
Built: | 2024-12-13 05:58:36 UTC |
Source: | https://github.com/bioc/tkWidgets |
Takes a path and returns a vector of string with the names of files and directories for the path. The directory names will have a system dependent path separator (e. g. / for Unix) appended.
appendSepDir(path)
appendSepDir(path)
path |
|
A character vector containing file and directory names.
Jianhua (John) Zhang
# File names and directory names are not differentiated list.files() # Put a separater at the end of directory names appendSepDir(getwd())
# File names and directory names are not differentiated list.files() # Put a separater at the end of directory names appendSepDir(getwd())
This function reads the formal arguments to a given function and converts the content into an XML format
args2XML(fun, xml.name = "", full.names = NULL, priority = NULL)
args2XML(fun, xml.name = "", full.names = NULL, priority = NULL)
fun |
|
xml.name |
|
full.names |
|
priority |
|
Priority values are currently used to determine whether the argument will appear on a widget that has entry boxes for modifying the values of the arguments. Users of args2XML may not have any concern of the priority values
No value will be returned.
Jianhua Zhang
fullNames <- c("Full path names", "Pattern to match", "Visiable file names", "Include path") args2XML(list.files, "temp.xml", fullNames, c(1, 2, 2, 2)) readLines("temp.xml") unlink("temp.xml")
fullNames <- c("Full path names", "Pattern to match", "Visiable file names", "Include path") args2XML(list.files, "temp.xml", fullNames, c(1, 2, 2, 2)) readLines("temp.xml") unlink("temp.xml")
Given a argument list, the functions construct a widget to allow users to entry or select values for arguments defined by the names of the argument list.
argsWidget(argsList, defaultNames, inst = "") getPWidget(argsList, PWEnv, inst = "") formatArg(toFormat) getSymbol(args) funcs2Char(args,funcs) getTrueNullNa(toFormat)
argsWidget(argsList, defaultNames, inst = "") getPWidget(argsList, PWEnv, inst = "") formatArg(toFormat) getSymbol(args) funcs2Char(args,funcs) getTrueNullNa(toFormat)
argsList |
|
PWEnv |
|
toFormat |
|
args |
|
funcs |
|
defaultNames |
|
inst |
|
argsWidget
builds a widget with widget elements to allow
users to input values for the arguments.
getPWidget
instatiates primary widgets that will be used
to construct the widget for argements.
formatArg
formats the value for a given argument so that
the calue can be displayed by a tcltk widget.
getSymbol
filters out functions from the argument list.
funcs2Char
converts functions to character
representations of the functions.
getTrueNullNa
converts string "true", "false", "null",
and "na" to R primitives for these items.
argsWidget
returns a list with user input values for
elements of the argument list passed.
getPWidget
returns a list of primary widgets.
formatArg
returns a list containing the formated values.
getSymbol
returns a list containing arguments that are
functions.
funcs2Char
returns a list containing character
representations of functions.
getTrueNullNa
returns an R object.
Jianhua Zhang
R tcltk
if(interactive()){ argsWidget(list("Entry with default" = "default", "Entry without default" = "")) }
if(interactive()){ argsWidget(list("Entry with default" = "default", "Entry without default" = "")) }
This class is for keeping information about a data frame to
be processed. The class is mainly for use by importWizard
Objects can be created by calls of the form new("colInfo", ...)
colName
:Object of class "character"
- a
character string for the name of the column
colType
:Object of class "character"
- a
character string for the data type of the column. Can only be
"character" or "numeric"
dropOrNot
:Object of class "logical"
- a
boolean indicationg whether the column will be droped
signature(object = "character")
: The get
method for slot "colName"
signature(object = "character")
: The set
method for slot "colName"
signature(object = "character")
: The get
method for slot "colType"
signature(object = "character")
: The set
method for slot "colName"
signature(object = "logical")
: The get
method for slot "dropOrNot"
signature(object = "logical")
: The set
method for slot "dropOrNot"
Jianhua Zhang
newInfo <- new("colInfo", colName = "aaaa", colType = "character", dropOrNot = FALSE)
newInfo <- new("colInfo", colName = "aaaa", colType = "character", dropOrNot = FALSE)
This function creates a widget to allow users to view the content of a data frame passed and decide whether to save the data or not.
dataViewer(data, caption = "", save = TRUE)
dataViewer(data, caption = "", save = TRUE)
data |
|
caption |
|
save |
|
Taking a data frame as one of the arguments, this function builds a widget that allows users to view the content of the data and save the data as a file.
This function does not return any value
Jianhua Zhang
R tcltk
# Create matrix data <- matrix(1:20, ncol = 4) if(interactive()){ # View data using dataViewer dataViewer(data, "test", TRUE) }
# Create matrix data <- matrix(1:20, ncol = 4) if(interactive()){ # View data using dataViewer dataViewer(data, "test", TRUE) }
This functions creates a interactive widget to allow users to input arguments for database connection for Unix.
dbArgsWidget()
dbArgsWidget()
Database arguments include database name, user name, password, host name, and table name.
The function returns a list containing the following elements:
dbname |
a charater string for the name of the database |
host |
a character string for the name or IP address of the host machine |
user |
a character string for the name of the user |
password |
a character string for the password |
tablename |
a character string for the name of the database table |
Jianhua Zhang
Rdbi
if(interactive()){ test <- dbArgsWidget() }
if(interactive()){ test <- dbArgsWidget() }
These functions construct a widget that allow users to visually explore a data package of Bioconductor and read selected elements to R
DPExplorer(pkgName = "", title = "BioC Data Package Explorer", getFocus = TRUE) getTopLevel(title) loadDataPkg(pkgName)
DPExplorer(pkgName = "", title = "BioC Data Package Explorer", getFocus = TRUE) getTopLevel(title) loadDataPkg(pkgName)
pkgName |
|
title |
|
getFocus |
|
If pkgName
is not provided when DPExplorer
is
called, an entry box is available for users to put a pkgName
in
later. In either cases, the data package specified by pkgName
should have been loaded.
getTopLevel
creates a top level window for the widget.
loadDataPkg
filters out valid environment objects from a
data package.
If only one key is selected, DPExplorer
returns a vector
of one to more elements. If more than one key is selected,
loadDataPkg
returns a list of vectors.
getTopLevel
returns a tkwin object for the top level
window.
loadDataPkg
returns a vector of character strings for
available data environments.
Jianhua Zhang
Documents for a Bioconductor data package
if(interactive() && require("hgu95av2", character.only = TRUE)){ DPExplorer("hgu95av2") }
if(interactive() && require("hgu95av2", character.only = TRUE)){ DPExplorer("hgu95av2") }
Given a valid package name as a character string,
eExplorer
collects all the example code from the "R-ex"
directory from the R library for that package and then displays the
names of the code examples in a list box. When a name in the list box
is clicked, the corresponding code will be displayed and users are
allowed to execute the code or view the help file for the function the
example code is for.
eExplorer(pkgName, font = "arial 13", getFocus = TRUE) getExCode(pkgName) getHelpFile(pkgName, fileName)
eExplorer(pkgName, font = "arial 13", getFocus = TRUE) getExCode(pkgName) getHelpFile(pkgName, fileName)
pkgName |
|
font |
|
fileName |
|
getFocus |
|
getExCode
and getHelpFile
are called by
eExplorer
to get the code examples or help help files
contained by a given package.
eExplorer
does not return anything useful.
Jianhua Zhang
Writing R Extension for information on "R-ex" and "help" directories
if(interactive()){ require("Biobase") || stop("Does not run without Biobase") eExplorer("Biobase") }
if(interactive()){ require("Biobase") || stop("Does not run without Biobase") eExplorer("Biobase") }
This function provides the widget for users to go up and down a path and
view the files. When files are selected and the "End"
button
is pressed, the function returns a vector of character strings with
the full paths of the selected files.
fileBrowser(path="", testFun = function(x) TRUE, prefix = NULL, suffix = NULL, textToShow = "Select file(s)", nSelect = -1)
fileBrowser(path="", testFun = function(x) TRUE, prefix = NULL, suffix = NULL, textToShow = "Select file(s)", nSelect = -1)
path |
character string for the full path to be view. Defaults to the current working directory if no path is provided. |
testFun |
function that checks to see if a given file name satisfies predefined requirements. The default is no checking. |
prefix |
character string for a prefix used to screen out file names that do not have that prefix as part of their names. |
suffix |
character string for a suffix used to screen out file names that do not have that suffix as part of their names. |
textToShow |
character string to be shown on the widget to given instructions to users. |
nSelect |
integer indicating the number of files that should be
selected. No limitation if |
When a path is viewed, files will be displayed as they are and
directories will be displayed with a system file separator appended
(e.g. "/"
for Unix systems).
Single click on a file name will make the file selectable when the
select button is pressed. Multiple selection is possible by dragging
with mouse button 1 pressed.
Double click on a directory name will go into that directory and
display its files. When a file/directory is selected and the "End" button
pressed, the full path for the selected files selected will be
returned.
The widget is modal and has to be closed by pressing the "End" button
before doing any other operations. Functions, prefix, and suffix can
be specified. Examples of validity functions are
hasPrefix
and hasSuffix
.
The following is a list of the buttons and their associated behavior:
Up
Moves the directory whose content is to be displayed in the box for file names one level up along the directory tree. No action if already on top of the tree.
Select \>\>
When a file or files in the box for file names in a directory have been highlighted by clicking or dragging mouse button 1 and this button is pushed, the highlighted file(s) will be displayed in the box for selected file(s) on the right.
\<\< Remove
When a file or files in the box for selected files have been highlighted by clicking or dragging this button is pushed, the highlighted file(s) will be removed from the box.
Clear
Clears everything in the box for selected files when pushed.
end
Returns a vector containing all the names in the box for
selected files or NULL
if the box is empty. The full path
will be appended to the file names.
A vector of character strings containing the full path of each file selected.
Jianhua (John) Zhang
pickFiles
,
hasPrefix
, hasSuffix
## The example here is only run interactively since it requires user ## interference which may cause problems if not available: if(interactive()) { # Call the function to view the current directory flist <- fileBrowser() flist # To call the function with a path do # fileBrowser(path = "yourPath") }
## The example here is only run interactively since it requires user ## interference which may cause problems if not available: if(interactive()) { # Call the function to view the current directory flist <- fileBrowser() flist # To call the function with a path do # fileBrowser(path = "yourPath") }
Given a file name, this function imports the text file into R.
fileWizard(filename = "", fun = read.table, file = "file", basic = c("header", "sep"), getFocus = TRUE)
fileWizard(filename = "", fun = read.table, file = "file", basic = c("header", "sep"), getFocus = TRUE)
filename |
A character string for the name of the text file to be imported |
fun |
An R function that is going to be used to read the
file. Default to |
file |
A character string for the name of the argument to fun that defines the name of the file to be read |
basic |
A vector of character strings for names of the arguments to fun that will have separate entry boxes on the widget to be produced. Default to "header" and "sep" |
getFocus |
|
This function is only partially finished and will be improved soon. It currently allows uesrs to view a given file and change the settings for header and sep arguments of read.table. A file will be read in based on the values of the two arguments and return.
This function returns a data frame for the file read in.
Jianhua Zhang
R News Vol. 1/3, September 2001
if(interactive()) { # Only the interface is displyed as no real file is given fileWizard() }
if(interactive()) { # Only the interface is displyed as no real file is given fileWizard() }
Given a text string and coordinations, this function creates a light weight tcltk widget with showing the text string passed.
getLightTW(x, y, text)
getLightTW(x, y, text)
x |
|
y |
|
text |
|
When the function is invoked, a box containing the text will appear at the position specified by x, and y. Click the widget makes it disappear.
This function does not return any value
Jianhua Zhang
if(interactive()){ getLightTW(200, 200, "Click Me!") }
if(interactive()){ getLightTW(200, 200, "Click Me!") }
This function returns a list containing the values for widgets on a widget created by function widgetRender. It takes a list defining the widget and returns a named list containing the values for each of the widgets.
getWvalues(W)
getWvalues(W)
W |
|
For a widget containing 3 widgets each with some associated functionalities, the list is defined as this:
pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse= ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse")
pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, collapse=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List")
pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL)
widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye")
widget1 will be used to create a widget with 3 entry boxes. When users modify the values through the widget created, new values will be kept in the list and widget1 will be returned up exist. getWvalues is useful to capture the values for each widgets on the widget.
This function returns a list of:
comp1 |
Description of ‘comp1’ |
comp2 |
Description of ‘comp2’ |
Jianhua Zhang
# Define the widgets pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse= ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, collapse=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") if(interactive()){ tt <- widgetRender(widget1, "try") getWvalues(tt) }else{ getWvalues(widget1) }
# Define the widgets pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse= ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, collapse=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") if(interactive()){ tt <- widgetRender(widget1, "try") getWvalues(tt) }else{ getWvalues(widget1) }
This function reads a few lines from a data text file and determines whether a header exists, what the delimiter, and what data type each column is for a given file.
guess.sep(file.name, numLine = 5, seps = "", isFile = TRUE) guess.header(twoLines, sep) find.type(file.name, sep, header = FALSE, numLine = 5, isFile = TRUE) charOrNum(vect) getRowNames(file.name, sep, header, skip)
guess.sep(file.name, numLine = 5, seps = "", isFile = TRUE) guess.header(twoLines, sep) find.type(file.name, sep, header = FALSE, numLine = 5, isFile = TRUE) charOrNum(vect) getRowNames(file.name, sep, header, skip)
file.name |
|
numLine |
|
seps |
|
twoLines |
|
sep |
|
vect |
|
header |
|
isFile |
|
skip |
|
guess.sep calls guess.sep
and find.type
to
determine the header, delimiter, and column data type of a file.
charOrNum
determines which elements of a vector are
numeric or character.
This function returns a list containing
header |
TRUE if there is a header and FALSE otherwise |
separater |
A character string indicating the delimiter used |
type |
A vector of character strings that are either character or numeric |
Jianhua Zhang
# Create a temp file tempData <- matrix(1:20, ncol = 4) write.table(tempData, file = "tempData", quote = FALSE, sep = "\t", row.names = FALSE, col.names = TRUE) guess.sep("tempData") unlink("tempData")
# Create a temp file tempData <- matrix(1:20, ncol = 4) write.table(tempData, file = "tempData", quote = FALSE, sep = "\t", row.names = FALSE, col.names = TRUE) guess.sep("tempData") unlink("tempData")
These functions return a function for determining if a given prefix, suffix, or set of characters passed to this function exists in a character string passed to the returned function.
hasChar(toCheck, what = "") hasPrefix(aPrefix) hasSuffix(aSuffix)
hasChar(toCheck, what = "") hasPrefix(aPrefix) hasSuffix(aSuffix)
aPrefix |
character string to be used as the prefix to be checked for |
aSuffix |
character string to be used as the suffix to be checked for |
toCheck |
|
what |
|
The prefix (or suffix) is passed to hasPrefix
(or
hasSuffix
) and then the returned function can be used to check
for the existence of that prefix (suffix) in a string passed to that
function.
hasChar is a more general function that determines the existence of prefix, sufix, or a set of a characters in a character string passed to the returned function.
A function which itself returns a logical (of length 1)
indicating if the prefix/suffix is found (TRUE
) or not.
Jianhua (John) Zhang
# Function for checking for a prefix "xxx" : chkPfun <- hasChar("xxx", what = "prefix") # Function for checking for a suffix ".tex" : chkSfun <- hasChar(".tex", what = "suffix") chkPfun("xxx.tex") chkPfun(".xxx") chkSfun("xxx.tex") chkSfun("yyyyy") chkSfun("yxxx.text")
# Function for checking for a prefix "xxx" : chkPfun <- hasChar("xxx", what = "prefix") # Function for checking for a suffix ".tex" : chkSfun <- hasChar(".tex", what = "suffix") chkPfun("xxx.tex") chkPfun(".xxx") chkSfun("xxx.tex") chkSfun("yyyyy") chkSfun("yxxx.text")
This functions allow users to read data from an existing file or an R data.frame object and use the data frame to construct an AnnotatedDataFrame object.
importPhenoData(fileName, sampleNames = NULL, from = NULL) createPData(pdata, varList) writePDRowNames(pdata, sampleNames) writePhenoTable(base, textWidget, pdata) makePhenoData(pdata) convert2PData(phenoList) getOBJWidget(type = NULL) objExists(name, type = NULL) getSNCNums(sampleNames) getCovarDesc(varList)
importPhenoData(fileName, sampleNames = NULL, from = NULL) createPData(pdata, varList) writePDRowNames(pdata, sampleNames) writePhenoTable(base, textWidget, pdata) makePhenoData(pdata) convert2PData(phenoList) getOBJWidget(type = NULL) objExists(name, type = NULL) getSNCNums(sampleNames) getCovarDesc(varList)
fileName |
a character string for the name of a file that is going to be used to build an AnnotatedDataFrame object. |
sampleNames |
a vector of character strings for the names of samples. The
length of |
pdata |
a data.frame for the experimental data. |
base |
an RTcl object for the base window a widget resides. |
textWidget |
an RTcl object for a text box widget. |
phenoList |
a list of lists for tclVar() objects. |
type |
a character string for the class of a object e.g. data.frame, AnnotatedDataFrame. |
name |
a character string for the name of an object. |
varList |
a list of characters with names being covariate names and values being short descriptions of covariate names. |
from |
a character string indicating how an AnnotatedDataFrame object will
be created. "file" - create from an existing file, "object" - create from an
existing data frame object, "edit" - create by editing an existing
AnnotatedDataFrame object, and "new" create a new AnnotatedDataFrame object
from scratch. NULL or any other values for |
When import a data.frame or AnnotatedDataFrame object, the object to be imported should have been stored in .GlobelEnv. All the objects of data.frame or AnnotatedDataFrame will be made available through a browser.
The main widget if importPhenoData
that calls other
functions/widgets to have the job done.
Package Biobase is required for importPhenoData but the requirement id not forced as it is the only time the package is used. Users have to make sure that Biobase is available.
An AnnotatedDataFrame object.
This function is intended for use by function read.phenoData of Biobase
Jianhua Zhang
AnnotatedDataFrame class in Biobase
if(interactive()){ importPhenoData() }
if(interactive()){ importPhenoData() }
Functions constructs a widget that allows users to inport data file to R. The imported data will be returned as an R data frame together with the argument list used to import the data using read.table
importWizard(filename = "", maxRow = 400) initImportWizard(env) getTopCan(base, env) getAFrame(base, env) finish(env) getState1Frame(base, env) setState1BFrame(frame, env) setState1TFrame(frame, viewer, delims, env, startList) showData4State1(widget, env) setState1MFrame(frame, env, dataViewer) getState2Frame(base, env, state = "state2", reset = FALSE) setState2MFrame(frame,env) setSepRadios(frame, env, state = "state2") setQuoteList(frame, env) setQuote(listBox, env, state = "state2") setState2BFrame(frame, env) showData4State2(canvas, env, state = "state2") getState3Frame(base, env) setState3TFrame(frame, env) setState3BFrame(frame, env) getName4Data(filename, objType) writeCol4Matrix(tempFrame, dataFile, colInfos, env) popStartLine(startList, env) readFileByLines(filename)
importWizard(filename = "", maxRow = 400) initImportWizard(env) getTopCan(base, env) getAFrame(base, env) finish(env) getState1Frame(base, env) setState1BFrame(frame, env) setState1TFrame(frame, viewer, delims, env, startList) showData4State1(widget, env) setState1MFrame(frame, env, dataViewer) getState2Frame(base, env, state = "state2", reset = FALSE) setState2MFrame(frame,env) setSepRadios(frame, env, state = "state2") setQuoteList(frame, env) setQuote(listBox, env, state = "state2") setState2BFrame(frame, env) showData4State2(canvas, env, state = "state2") getState3Frame(base, env) setState3TFrame(frame, env) setState3BFrame(frame, env) getName4Data(filename, objType) writeCol4Matrix(tempFrame, dataFile, colInfos, env) popStartLine(startList, env) readFileByLines(filename)
filename |
|
maxRow |
|
env |
|
base |
|
frame |
|
viewer |
|
delims |
|
widget |
|
state |
|
listBox |
|
canvas |
|
tempFrame |
|
dataFile |
|
colInfos |
|
reset |
|
dataViewer |
|
objType |
|
startList |
|
importWizard
mimics the interface of MS Excel and
collects arguments for the function read.table
. Due to
performace concern, a maximum number of rows (maxRow) set by
users will be displayed. Overly long data set may cause slow response
of the system.
initImportWizard
initializes the interface for
importWizard by creating a widget with an empty top canvas and bottom
frame filled with four buttons.
getTopCan
Creates a canvas that is going to be filled by
a frame created by other functions depending on the state of the
importing process.
getAFrame
Gets a frame for the canvas created by
initImportWizard
based on the current state of importing
process.
finish
Finishes the importing process and returns a data
frame read from a file using read.table
.
getState1Frame
Returns a tcltk frame containing a list
box to show a data file read by readLines
and widgets
for user imports.
setState1BFrame
Fills the bottom frame of the frame
created by getState1Frame
with a list box.
setState1TFrame
Fills the top frame of the frame
created by getState1Frame
with a list box.
showData4State1
Populates a tcltk list or text widget
with data read using readLines.
setState1MFrame
Fills the mid frame of the frame
created by getState1Frame
.
getState2Frame
Returns a tcltk frame containing a canvas
to show a data file read by read.table
and widgets
for user imports.
setState2MFrame
Fills the mid frame of the frame
created by getState2Frame
.
setSepRadios
Renders radio buttons for options of file
separators in the frame created by setState2MFrame
.
setQuoteList
Renders the selection list for the quote
used by a data file in the frame created by
setState2MFrame
.
setQuote
Sets the value when a user has selected the
quote used by a data file.
setState2BFrame
Fills the bottom frame of the frame
created by getState2Frame
with a canvas.
showData4State2
Populates the canvas created by
setState2BFrame
using data read by
read.table
.
getState3Frame
Returns a tcltk frame containing a canvas
to show a data file read by read.table
and widgets
for user imports.
setState3TFrame
Fills the top frame of the frame
created by getState3Frame
.
setState3BFrame
Fills the bottom frame of the frame
created by getState3Frame
.
getName4Data
Takes user input for a file name using a
widget.
writeCol4Matrix
Creates a tcltk frame with list boxes as
columns displaying data of a data matrix.
getTopCan
returns a tcltk canvas.
getAFrame
returns a tcltk frame.
finish
returns a data.frame.
getState1Frame
returns a tcltk frame with several
widgets.
setState1BFrame
returns the tkwin object of list box.
getState2Frame
returns a tcltk frame with several
widgets.
getState3Frame
returns a tcltk frame with several
widgets.
getName4Data
returns a character string for the name of
a file to be saved.
Jianhua Zhang
if(interactive()){ importWizard() }
if(interactive()){ importWizard() }
These functions create a widget with selection boxes allowing users to view and make selections of items shown on the interface.
listSelect(aList, topLbl = "Select Elements From The Following List", typeFun = stdType, valueFun = stdView) writeSelBox(baseW, aList, typeFun = NULL, valueFun = NULL) writeBut(baseW, butList, butWidth = 6) writeLabel(baseW, typeFun, valueFun)
listSelect(aList, topLbl = "Select Elements From The Following List", typeFun = stdType, valueFun = stdView) writeSelBox(baseW, aList, typeFun = NULL, valueFun = NULL) writeBut(baseW, butList, butWidth = 6) writeLabel(baseW, typeFun, valueFun)
aList |
list with names and object pairs (e. g. |
topLbl |
character string for the text to be shown as a title. |
typeFun |
function that takes an R object as an arguement and returns a description of the object. |
valueFun |
function that takes an R object as an argument
and shows the content of the object. The function should get the
representation of the object and calls |
baseW |
a window widget to which the selection boxes will be put. |
butList |
a list with names and function pairs that define the name and behavior of buttons to be put on the widget to be generated |
butWidth |
numerical value specifying the width of buttons to be created. |
Both typeFun
and valueFun
have to take an argument (the
R object to be shown). It works well for the valueFun
function to call objViewer()
with whatever to be shown
passed to objViewer
as an argument.
listSelect()
returns a list with the names of the R objects in the
original list associated with TRUE
(selected) or FALSE
(deselected).
Jianhua Zhang
aList <- list(a = "AAA", b = c(123, 456, 789), c = as.data.frame(matrix(1:10, ncol = 2)), d = stdType) # Since user interference is required, the example code does not run # automatically if(interactive()) listSelect(aList)
aList <- list(a = "AAA", b = c(123, 456, 789), c = as.data.frame(matrix(1:10, ncol = 2)), d = stdType) # Since user interference is required, the example code does not run # automatically if(interactive()) listSelect(aList)
This widget allows uers to view and select objects from the
workspace. When the End
button is pressed, the selected objects
will be returned as a list.
objectBrowser(env = .GlobalEnv,fun = noAuto, textToShow = "Select object(s)", nSelect = -1)
objectBrowser(env = .GlobalEnv,fun = noAuto, textToShow = "Select object(s)", nSelect = -1)
fun |
function to test whether certain conditions are met by the objects. Only objects that meet the conditions will be displayed. |
textToShow |
character with the message to be shown on the widget as an instruction. |
nSelect |
integer indicating the number of objects to select.
No limitation if |
env |
|
This function will return a list of lists with a "name" and "obj" pair for each object selected. The "name" will be the name of the object and "obj" will be the value of the object. If the object is a package, a description of the contents of the package will be the value. If the selected object is a function, a text string of the original code will be the value. A function can be passed to impose a filtering mechanisms on the objects to be displayed. See function isCharacter for an example of writing a filtering function for objectBrowser.
The buttons and their expected behavior are
Up
Moves one level up along the search list and displays the content in the box for object names on the left of the widget.
Select \>\>
When objects in the box for object names have been highlighted by clicking or clicking/dragging, this button will display the highlighted object names in the box for selected objects on the right.
Reset
Moves back to .GlobalEnv
which
is the default starting point of the system.
\<\< Remove
When object names in the box for selected objects have been highlighted by clicking or clicking/dragging and this button is pressed, the highlighted object names will be removed from the display.
Clear
Removes all the object names from the box for selected objects.
Cancel
Exits the widget and returns NULL
when
pressed.
End
Returns a list
of lists with names of the
objects in the box for selected objects and their corresponding values
or NULL
if nothing exists in the box.
A list
of lists with a name and value pair for each object.
Jianhua (John) Zhang
## The example here is only run interactively since it requires user ## interference which may cause problems if not available: if(interactive()) { # Call the function with the isCharacter function. r <- objectBrowser() str(r) # show what we've got }
## The example here is only run interactively since it requires user ## interference which may cause problems if not available: if(interactive()) { # Call the function with the isCharacter function. r <- objectBrowser() str(r) # show what we've got }
This function supports objectBrowser
by converting a
vector of selected object names to a list of lists with object names
and the corresponding objects.
objNameToList(objNames, env)
objNameToList(objNames, env)
objNames |
character vector giving the names of objects. |
env |
an R environment where R objects are stored |
Each list in the list that is going to be returned contains a name for the object and the real value of the object. If the object name is a package name, the contents of the package will be the value associated with the package name.
A list of lists each with a name
and an obj
component.
Jianhua (John) Zhang
# Create two R objects obj1 <- c("aaa", "bbb", "ccc") env1 <- new.env(parent = baseenv()) # Get a list containing the two objects nl <- objNameToList(c("obj1", "env1"), parent.frame()) str(nl)
# Create two R objects obj1 <- c("aaa", "bbb", "ccc") env1 <- new.env(parent = baseenv()) # Get a list containing the two objects nl <- objNameToList(c("obj1", "env1"), parent.frame()) str(nl)
This function takes an R object and shows the content in a list box on a widget.
objViewer(toView, width = 40, height = 10)
objViewer(toView, width = 40, height = 10)
toView |
R object whose content is to be viewed |
width , height
|
positive values specifying the width and height of the widget. |
The function makes no check of the R object passed and will show whatever the object will be shown when the name is type at an R prompt. Formatting is required before passing the R object to the function.
This function does not return any value
Jianhua Zhang
# Since user interference is required, the example code only runs # interactively if(interactive()) objViewer("Just to show that the content gets posted")
# Since user interference is required, the example code only runs # interactively if(interactive()) objViewer("Just to show that the content gets posted")
This widget allows users to explore R packages in the R library and try the example code.
pExplorer(pkgName = "", pkgPath = "", exclude = getExclude(), getFocus = TRUE) getPkgContents(pkgName, exclude = getExclude()) getFileContents(path, fileName) getExclude() getRPkgs(pkgPath) hasDesc(pkgPath) procRda(fileName) procHelp(fileName) procPDF(fileName) procHTML(fileName)
pExplorer(pkgName = "", pkgPath = "", exclude = getExclude(), getFocus = TRUE) getPkgContents(pkgName, exclude = getExclude()) getFileContents(path, fileName) getExclude() getRPkgs(pkgPath) hasDesc(pkgPath) procRda(fileName) procHelp(fileName) procPDF(fileName) procHTML(fileName)
pkgPath |
|
path |
|
pkgName |
|
fileName |
|
exclude |
|
getFocus |
|
With or without a package name, the widget will have all the installed
R package names in a dropdown list for user to select. As the default,
the first element from list.files
will be selected and
the contents displayed if no package name is given.
getPkgContents
gets the contents of a given R package
and getFileContents
gets the contents of a givan file.
getRPkgs
, hasDesc
, procRda
,
procHelp
, procPDF
, and
procHTML
are functions called by
pExplorer
to process different file or directory types.
The widget returns invisiable()
Jianhua Zhang
Documentation on R packages
require("tkWidgets") || stop("tkWidgets not available") getPkgContents(.libPaths(), "tkWidgets") getFileContents(file.path(path.package("tkWidgets"), "help"), list.files(file.path(path.package("tkWidgets"), "help"))[1]) if(interactive()){ pExplorer() }
require("tkWidgets") || stop("tkWidgets not available") getPkgContents(.libPaths(), "tkWidgets") getFileContents(file.path(path.package("tkWidgets"), "help"), list.files(file.path(path.package("tkWidgets"), "help"))[1]) if(interactive()){ pExplorer() }
Takes a vector of strings and then checks to see if the predefined conditions are met for each element. Elements that meet the conditions will be included in the vector returned and the others not.
pickFiles(fileNames, fun = function(x) TRUE, prefix = NULL, suffix = NULL, exclude = .Platform$file.sep)
pickFiles(fileNames, fun = function(x) TRUE, prefix = NULL, suffix = NULL, exclude = .Platform$file.sep)
fileNames |
vector of strings that will be checked. |
fun |
function to be used to check the strings. Default is no checking. |
prefix |
character used to check to see if strings in the vector have the prefix. |
suffix |
character used to check to see if strings in the vector have the suffix. |
exclude |
character string with which strings in the vector will be excluded form the checking. The default is to exclude all the directory names and always return them. |
The function fun will be used only when both prefix and suffix are NULL. If a prefix is not NULL, that prefix will be checked. A suffix is going to be checked when prefix is NULL.
Character vector of file names satisfying the conditions.
Jianhua Zhang
fileBrowser
, hasPrefix
, hasSuffix
# Return every thing from the current directory pickFiles(list.files()) # Create a temp file file.create("myFile") # Returns subdirectory names and file names with a prefix of "my" pickFiles(list.files(), prefix = "my") # create another temp file file.create("temp.tex") # Return subdirectory names and file names with a suffix of ".tex" pickFiles(list.files(), suffix = ".tex") # clearn up unlink("myFile") unlink("temp.tex")
# Return every thing from the current directory pickFiles(list.files()) # Create a temp file file.create("myFile") # Returns subdirectory names and file names with a prefix of "my" pickFiles(list.files(), prefix = "my") # create another temp file file.create("temp.tex") # Return subdirectory names and file names with a suffix of ".tex" pickFiles(list.files(), suffix = ".tex") # clearn up unlink("myFile") unlink("temp.tex")
Given a vector of characters, this function creates a widget containing list box to allow users to visually select elements from the vector.
pickItems(items, title1 = "Items to pick", title2 = "Picked items")
pickItems(items, title1 = "Items to pick", title2 = "Picked items")
items |
|
title1 |
|
title2 |
|
This function is to provide visual support to other functions and thus may not have much use otherwise.
This function returns a vector of select items.
Jianhua Zhang
R tcltk
options <- paste("Option", 1:10, sep = "") if(interactive()){ pickItems(options) }
options <- paste("Option", 1:10, sep = "") if(interactive()){ pickItems(options) }
This function takes a vector of object names and determines what will
be sent to (e.g. the objectBrowser
) widget for display
based on the default and user input requirements.
pickObjs(objNames, fun = noAuto) noAuto(x)
pickObjs(objNames, fun = noAuto) noAuto(x)
objNames |
|
fun |
|
x |
|
Packages and environments are always displayed.
Character vector of object names that satisfy the requirements.
Jianhua (John) Zhang
# Returns names of package and environment objects in the search path. pickObjs(search())
# Returns names of package and environment objects in the search path. pickObjs(search())
The functions are to support importWizard and may not have much practical use otherwise.
setArgsList(filename, env, isFile = TRUE, init = TRUE) whatDeli(delimiter) getMoreArgs() assignArgs(value, env) getArgs(env) assignShowNum(value, env) getShowNum(env) assignCState(value, env) getCState(env) assignColInfo(value, env) getColInfo(env) setColInfos(types, env) changeState(canvas, backBut, nextBut, env, forward = TRUE, endBut, viewBut) setNewState(env, backBut, nextBut, forward = TRUE, endBut, viewBut) addArgs(env) dropArgs(env) setSkip(widget, env, state = "state1") moreArgs(env) dropColumn(index, env) setColName(index, entryBox, env) setColType(index, entryBox, env) assignLineData(lineData, env) getLineData(env)
setArgsList(filename, env, isFile = TRUE, init = TRUE) whatDeli(delimiter) getMoreArgs() assignArgs(value, env) getArgs(env) assignShowNum(value, env) getShowNum(env) assignCState(value, env) getCState(env) assignColInfo(value, env) getColInfo(env) setColInfos(types, env) changeState(canvas, backBut, nextBut, env, forward = TRUE, endBut, viewBut) setNewState(env, backBut, nextBut, forward = TRUE, endBut, viewBut) addArgs(env) dropArgs(env) setSkip(widget, env, state = "state1") moreArgs(env) dropColumn(index, env) setColName(index, entryBox, env) setColType(index, entryBox, env) assignLineData(lineData, env) getLineData(env)
filename |
|
env |
|
delimiter |
|
value |
|
backBut |
|
nextBut |
|
forward |
|
widget |
|
state |
|
index |
|
entryBox |
|
a tcltk entry box.
canvas |
|
types |
|
lineData |
|
endBut |
|
viewBut |
|
init |
|
isFile |
|
setArgsList
calls function guess.sep
to
figure out the the header, sep, and data type of a file and sets the
values for argument list and colInfo.
whatDeli
gets the word representation of delimiters
(e.g. tab for "\t").
getMoreArgs
generates a widget using widgetTools to
collect some of the arguments for read.table.
assignArgs
updates "argsList" stored in a predefined
environment.
getArgs
Gets "argsList" from a predefined environment.
assignShowNum
Updates the value for "showNum" (number of
rows to show in the interface.
getShowNum
Gets the value for "showNum" (number of
rows to show in the interface.
link{assignCState}
Updates the value of "currentState" that is
stored in a predefined environment.
getCState
Gets the vlaue of "currentState" that is
stored in a predefined environment.
assignColInfo
Updates the values of "colInfos" (column
information) that is stroed in a predefined environment.
getColInfo
Gets the values of "colInfos" (column
information) that is stroed in a predefined environment.
setColInfos
Creates colInfo objects and sets the value
of 'colInfos' list.
changeState
changes the state and thus the interface of
a widget.
setNewState
sets the state of a importing process.
addArgs
adds a new state to the argument list for
states.
dropArgs
removes a state from the argument list for
states.
setSkip
Sets the value for the number of lines to skip
when readling a data file.
moreArgs
Gets some of the arguments for importing data
using read.table
.
dropColumn
Sets the index values for data columns that
are going to be droped when read using read.table
.
setColName
Sets the column names for a data file by
getting column names from correct entry boxes.
setColType
Sets the column type for a data file by
getting column type information from correct entry boxes.
whatDeli
returns a character string.
getMoreArgs
returns a list of arguments.
getArgs
returns a list of the arguments for read.table.
getShowNum
returns an integer for the number of rows to
show.
getCState
returns a character string for the current
state.
getColInfo
returns a colInfo object contains column
information.
Jianhua Zhang
# No example is given as functions require the set up of the working # environment.
# No example is given as functions require the set up of the working # environment.
The function listSelect
takes two functions which define
how the type information and content of R objects will be shown on
the widget created by listSelect
.
Functions stdType()
and stdView()
provide the default
behavior.
stdType(toCheck) stdView(toView)
stdType(toCheck) stdView(toView)
toCheck , toView
|
arbitrary R object. |
These functions can be viewed as exmaples of defining functions for
the typeFun
and valueFun
arguments of the
listSelect
function.
stdType()
returns a character string describing the type of the
R object.
stdView()
Jianhua Zhang
stdType(123) stdType("What am I") str(mydf <- data.frame(x = 2:8, ch = letters[1:7])) stdType(mydf)# "list" stdType(stdType) if(interactive()) {## stdView() needs UI: stdView(1:10) stdView(mydf) }
stdType(123) stdType("What am I") str(mydf <- data.frame(x = 2:8, ch = letters[1:7])) stdType(mydf)# "list" stdType(stdType) if(interactive()) {## stdView() needs UI: stdView(1:10) stdView(mydf) }
This function provides a widget for users to enter experimental design MIAME information.
tkMIAME()
tkMIAME()
This widget provides an interface to enter experimental information following the MIAME (Minimum Information About a Microarray Experiment) standard.
A draft of the latest document (v. 1.1) is http://www.mged.org/Workgroups/MIAME/miame_1.1.html
Brazma et al. divide the MIAME into 6 sections
1. Experimental design, 2. Array design, 3. Samples, 4. Hybridizations,
5. Measurements, and 6. Normalization controls
This widget is for the first section.
We ask for the user to enter: experimenter name,
laboratory, contact information, a single-sentence experiment title, an
abstract describing the experiment, URLs. This slot could also include a
formal statistical description of the experimental design (e.g. using
factors). Some of this info is already stored in
AnnotatedDataFrame
or
elsewhere.
The function returns a list that is intended for the creation of an
object of class MIAME
. However, we
return a list so that the function can work independently of the Biobase
package.
A list containing entries:
ExperimentName |
character string |
LabName |
character string |
ContactInfo |
character string |
ExperimentTitle |
character string |
Description |
character string |
URL |
character string |
Majnu John
“Minimum information about a microarray experiment (MIAME)-toward standards for microarray data”, A. Brazma, et al., Nature Genetics, vol. 29 (December 2001), pp. 365-371, http://www.mged.org/Workgroups/MIAME/miame_1.1.html
This widget provides an interface to create
AnnotatedDataFrame-class
instances.
tkphenoData(sampleNames)
tkphenoData(sampleNames)
sampleNames |
sampleNames for which we will enter phenotypic data. |
The function returns a list of character matrices intended to be used
as the pData
and varLabels
slots of an instance of
AnnotatedDataFrame-class
.
A list of two matrices
pData |
a character matrix containing phenotypic data. |
varLabels |
a character vector with covariate description. |
Majnu John
This widget provides an interface to enter names to be associated with files containing array expression information related to a particular sample.
tkSampleNames(..., filenames = character(0))
tkSampleNames(..., filenames = character(0))
... |
the filenames to be associated with a sample name, supplied individually and/or as a character vector |
filenames |
a character vector of filenames to be associated with a sample name. |
AnnotatedDataFrame-class
objects will use sample names
as row names for its pData. The colnames of the expression matrices in
ExpressionSet-class
use
this as well. Many times, each
of these columns are obtained from a file. Rather than use the,
sometimes ugly, filename we can use the sample names that this
interface associates with each file.
The function returns a character matrix intended to be used to create sample names in AnnotatedDataFrame and ExpressionSet. However, the function can be used independently of the Biobase package.
A character matrix with the first column the filenames the second column the sample names to associate.
Majnu John
Functions in this group print or list the names or/and values of the
widget elements on a widget created by widgetRender()
.
values.Widget(x)
values.Widget(x)
x |
A list (print.pWidget) or list of lists(print.Widget, values.Widget) that representing a widget element (list) on a widget or a widget (list of lists) generated by using the function widgetRender. |
print.pWidget takes a list defining a widget element on a widget generated by using the function widgetREnder. An example of a valid list will be:
pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse")
print.Widget and values.Widget take a list of lists defining all the widget elements on a widget generated using the function widgetRender. An example of a valid list will be:
pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse")
pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, sep=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List")
pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL)
widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye")
returnList |
values.Widget returns a list of lists each with the name and value of an entry box on the widget created. |
Jianhua (John) Zhang
# Create the lists and list of lists pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, sep=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") # Define the classes class(pW1) <- c("pWidget", "textbox") class(widget1) <- "Widget" # Call the funcitons print.pWidget(pW1) print.Widget(widget1) values.Widget(widget1)
# Create the lists and list of lists pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, sep=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") # Define the classes class(pW1) <- c("pWidget", "textbox") class(widget1) <- "Widget" # Call the funcitons print.pWidget(pW1) print.Widget(widget1) values.Widget(widget1)
This function provides a widget for viewing, editing, and executing code chunks of vignettes.
vExplorer(title = "BioC Vignettes Explorer", pkgName = "", font = ifelse(.Platform$OS.type == "unix", "arial 14", "arial 11")) viewVignette(title, packName, vigPath, font = "arial 11")
vExplorer(title = "BioC Vignettes Explorer", pkgName = "", font = ifelse(.Platform$OS.type == "unix", "arial 14", "arial 11")) viewVignette(title, packName, vigPath, font = "arial 11")
title |
character string for the name to be displayed as the title of the widget to interact with code chunks. |
pkgName |
vector (of length 1 for |
packName |
same as pkgName |
vigPath |
character string for the full qualified name of a vignette to be explored. |
font |
a character string for the name and size of the font to be used for text rendered on the widgets (e. g. "arial 11") |
By default, packNames = ""
, all the installed packages will be
examined and those that have vignettes will be listed to allow users
to choose from.
This function does not return any useful value.
This function is part of the Bioconductor project at Dana-Faber Cancer Institute to provide Bioinformatics functionalities through R.
Jianhua Zhang
if(interactive()){ require("DynDoc", character.only = TRUE) require("tools", character.only = TRUE) require("widgetTools", character.only = TRUE) vExplorer() path <- path.package("widgetTools") vigList <- pkgVignettes("widgetTools") viewVignette("BioC VignetteBrowser", "widgetTools", vigList$docs) }
if(interactive()){ require("DynDoc", character.only = TRUE) require("tools", character.only = TRUE) require("widgetTools", character.only = TRUE) vExplorer() path <- path.package("widgetTools") vigList <- pkgVignettes("widgetTools") viewVignette("BioC VignetteBrowser", "widgetTools", vigList$docs) }
This function takes a list that specifies the appearance and behavior of a Tk widget and renders the widget accordingly.
widgetRender(iWidget, tkTitle)
widgetRender(iWidget, tkTitle)
iWidget |
list of lists that specifies the appearance and behavior of the widget to be rendered. |
tkTitle |
character string for the text to appear in the title bar of the widget to be rendered. |
The widget to be rendered normally consists of frames with three widgets arranged in a row. The first widget is normally a label for the name of the second widget. The second widget can be any type of widgets. The third widget is a button widget that defines some behavior to be associated with the second widget. For example, a button that will cause something to be displayed in the second widget when pressed. The third widget can be missing if no such association is required.
The widget to be rendered also has two buttons at the bottom part of the widgets. The followings are the name and behavior of the buttons:
The unmodified list passed to the function at the time of invocation will be returned when pressed.
A modified version of the iWidget
argument will be returned when pressed. The returned list has the
same number of elements as the original one but with the values
modified based on the entries in corresponding widgets items.
A list
of lists with the original values of the passed
modified or unmodified depending on whether the cancel or end button
pressed.
Jianhua (John) Zhang
Peter Dalgaard (2001) A Primer on the R-Tcl/Tk Package; R News 1 (3), 27–31 http://CRAN.R-project.org/doc/Rnews/
# Create the list to be passed pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse= ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, collapse=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") # Call the function if(interactive()){ x <- widgetRender(widget1, "Test Widget") str(x) }
# Create the list to be passed pW1 <- list(Name="AAA", Value="bbb", toText=function(x) paste(x,collapse= ","), fromText=NULL, canEdit=TRUE, buttonFun = fileBrowser, buttonText = "Browse") pW2 <- list(Name="BBB", Value="x,y,z", toText=function(x) paste(x, collapse=","), fromText=NULL, canEdit=TRUE, buttonFun = ls, buttonText = "List") pW3 <- list(Name="CCC", Value="ccc", toText=function(x) paste(x, collapse = ","), fromText=NULL, canEdit=TRUE, buttonFun=NULL, buttonText=NULL) widget1 <- list(wList = list(a = pW1, b = pW2, c = pW3), preFun = function() "Hi", postFun = function() "Bye") # Call the function if(interactive()){ x <- widgetRender(widget1, "Test Widget") str(x) }
Currently primitive widget objects (pwidget
s) are implemented
as list
s, but this will change. Users should only rely
on these accessors functions, not the implementation.
WName(x) WValue(x) WValue(x) <- value WtoText(x) WfromText(x) WcanEdit(x) WbuttonText(x) WbuttonFun(x) WwList(x) WwList(x) <- value WLValue(x, index) WLValue(x, index) <- value WRButtons(x) WpreFun(x) WpostFun(x) WEnd(x)
WName(x) WValue(x) WValue(x) <- value WtoText(x) WfromText(x) WcanEdit(x) WbuttonText(x) WbuttonFun(x) WwList(x) WwList(x) <- value WLValue(x, index) WLValue(x, index) <- value WRButtons(x) WpreFun(x) WpostFun(x) WEnd(x)
x |
list of lists with a Name, Value, toText, fromText, canEdit, buttonText, buttonFun, preFun, postFun element. |
index |
integer or character string as an index or name for the list in the first list of a list of lists for a widget. |
value |
An R data type that is going to be used to update the value. |
WName(x)
returns the Name
element of x
.
WValue(x)
returns the Value
element of x
.
WValue(x) <- value
will change the Value
element of
x
to value
.
WtoText(x)
returns the toText
element of x
.
WfromText(x)
returns the fromText
element of x
.
WcanEdit(x)
returns the canEdit
element of x
.
WbuttonText(x)
returns the buttonText
element of x
.
WbuttonFun(x)
returns the buttonFun
element of x
.
WwList(x)
returns the wList
element of x
.
WwList <- value
will update the wList
element of a
Widget list with value
.
WLValue(x, index)
returns a list indicated by the
index in the wList of a widget list.
WLValue(x, index) <- value
will update indicated
by the index in the wList of a widget list with the value.
WpreFun(x)
returns the preFun element of x
.
WpostFun(x)
returns the post element of x
.
WEnd(x)
returns the end element of x
.
A character string or R function represented by the element of the list whose value is to be retrieved.
Jianhua (John) Zhang
widgetRender
for references etc.
# Create the list of lists pW1 <- list(Name="AAA", Value="bbb", toText = function(x) paste(x,collapse = ","), fromText = NULL, canEdit = TRUE, buttonFun = ls, buttonText = "Browse") widget1 <- list(wList = list(a = pW1), preFun = function() "Hi", postFun = function() "Bye") # Call the functions WName(pW1) WValue(pW1) WValue(pW1) <- "lll" WtoText(pW1) WfromText(pW1) WcanEdit(pW1) WbuttonText(pW1) WbuttonFun(pW1) WwList(widget1) WwList(widget1) <- list(Name = "New list", Value = "New value") WLValue(widget1, 1) WLValue(widget1, 1) <- "New value" WpreFun(widget1) WpostFun(widget1) WEnd(widget1)
# Create the list of lists pW1 <- list(Name="AAA", Value="bbb", toText = function(x) paste(x,collapse = ","), fromText = NULL, canEdit = TRUE, buttonFun = ls, buttonText = "Browse") widget1 <- list(wList = list(a = pW1), preFun = function() "Hi", postFun = function() "Bye") # Call the functions WName(pW1) WValue(pW1) WValue(pW1) <- "lll" WtoText(pW1) WfromText(pW1) WcanEdit(pW1) WbuttonText(pW1) WbuttonFun(pW1) WwList(widget1) WwList(widget1) <- list(Name = "New list", Value = "New value") WLValue(widget1, 1) WLValue(widget1, 1) <- "New value" WpreFun(widget1) WpostFun(widget1) WEnd(widget1)