Learn R Programming

PBSmodelling (version 2.67.266)

createWin: Create a GUI Window

Description

Create a GUI window with widgets using instructions from a Window Description File (aka mark-up file) .

Usage

createWin( fname, astext=FALSE, env=NULL )

Arguments

fname
name of window description file or list returned from parseWinFile.
astext
logical: if TRUE, interpret fname as a vector of strings with each element representing a line in a window description file.
env
an environment in which to evaluate widget callback functions; see example.

Details

Generally, the markup file contains a single widget per line. However, widgets can span multiple lines by including a backslash ('\') character at the end of a line, prompting the suppression of the newline character.

For more details on widget types and markup file, see “PBSModelling-UG.pdf” in the R directory .../library/PBSmodelling/doc.

It is possible to use a Window Description List produced by compileDescription rather than a file name for fname.

Another alternative is to pass a vector of characters to fname and set astext=T. This vector represents the file contents where each element is equivalent to a new line in the window description file.

See Also

parseWinFile, getWinVal, setWinVal

closeWin, compileDescription, createVector

initHistory for an example of using astext=TRUE environment

Examples

Run this code
## Not run: 
# # See file .../library/PBSmodelling/testWidgets/LissWin.txt
# # Calculate and draw the Lissajous figure
# local(envir=.PBSmodEnv,expr={
#   drawLiss <- function() {
#     oldpar = par(no.readonly=TRUE); on.exit(par(oldpar))
#     getWinVal(scope="L"); ti=2*pi*(0:k)/k;
#     x=sin(2*pi*m*ti);     y=sin(2*pi*(n*ti+phi));
#     plot(x,y,type=ptype); invisible(NULL); };
#   createWin(system.file("testWidgets/LissWin.txt",package="PBSmodelling"));
# })
# 
# ############################################################
# # Environment example:
# # function in global
# local(envir=.PBSmodEnv,expr={
#   hello <- function() {
#     stop( "I shouldn't be called" )
#   }
# 
# newNameGreeter <- function( name ) {
#   # method to display window
#   greet <- function() {
#     createWin(c("button \"Say hello\" func=hello"), astext=TRUE,
#       env=parent.env(environment()))
#   }
#   # hello method will refer to the name in this local scope
#   hello <- function() {
#     cat( "Hello", name, "\n" )
#   }
#   # return functions which the user can call directly
#   return( list( greet=greet, hello=hello ) )
# }
# alex <- newNameGreeter( "Alex" )
# jon  <- newNameGreeter( "Jon" )
# 
# alex$hello() # prints hello Alex
# jon$hello()  # prints hello Jon
# alex$greet() # creates a GUI with a button, which will print "hello Alex" when pushed
# })
# ## End(Not run)

Run the code above in your browser using DataLab