Title: | Creates an interactive tcltk widget |
---|---|
Description: | This packages contains tools to support the construction of tcltk widgets |
Authors: | Jianhua Zhang |
Maintainer: | Jianhua Zhang <[email protected]> |
License: | LGPL |
Version: | 1.85.0 |
Built: | 2024-12-18 04:08:41 UTC |
Source: | https://github.com/bioc/widgetTools |
This class defines the behavior shared by primary widget object used to build a GUI type interface
Objects can be created by calls of the form new("basicPW", ...)
.
Constructors have been defined to create objects of this class for
specific widgets such as buttons, list boxes, ..
wName
:Object of class "character"
- a string
for the name of the object
wType
:Object of class "character"
- a string
defining the type of the primary widget. (e.g. button)
wValue
:Object of class "ANY"
- the initial
value to be associated with the object
wWidth
:Object of class "numeric"
- an integer
for the width of the object to be rendered (if applicable)
wHeight
:Object of class "numeric"
- an integer
for the height of the object to be rendered (if applicable)
wFuns
:Object of class "list"
- a list of R
functions to be executed before the widget is activated
wPreFun
:Object of class "function"
- a list of
functions to be executed before the value of the widget to be updated
wPostFun
:Object of class "function"
- a list of
functions to be executed before the value of the widget to be retrieved
wNotify
:Object of class "list"
- a list of
functions to be executed each time when the value of the widget changes
wEnv
:Object of class "environment"
- an R
environment object within which the value of the object is stored
wView
:Object of class "widgetView"
- a object
of the class widgetView to which the widget is rendered
signature(object = "basicPW")
: Set the value for
wEnv slot
signature(object = "basicPW")
: Get the value for
wEnv slot
signature(object = "basicPW")
: Set the value
for wFuns slot
signature(object = "basicPW")
: Get the value for
wFuns slot
signature(object = "basicPW")
: Set the value
for wHeight slot
signature(object = "basicPW")
: Get the value
for wHeight slot
signature(object = "basicPW")
: Set the value
for wName slot
signature(object = "basicPW")
: Get the value for
wName slot
signature(object = "basicPW")
: Set the value
for wNotify slot
signature(object = "basicPW")
: Get the value
for wNotify slot
signature(object = "basicPW")
: Set the value
for wPostFun slot
signature(object = "basicPW")
: Get the value
for wPostFun slot
signature(object = "basicPW")
: Set the value
for wPreFun slot
signature(object = "basicPW")
: Get the value
for wPreFun slot
signature(object = "basicPW")
: Set the value
for wType slot
signature(object = "basicPW")
: Get the value for
wType slot
signature(object = "basicPW")
: Set the value
for wValue slot
signature(object = "basicPW")
: Get the value for
wValue slot
signature(object = "basicPW")
: Set the value
for wView slot
signature(object = "basicPW")
: Get the value for
wView slot
signature(object = "basicPW")
: Set the value
for wWidth slot
signature(object = "basicPW")
: Get the value for
wWidth slot
Jianhua Zhang
Programming with data
# 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 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)
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.
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)
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
# 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)
# 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)
The current tcltk library does not support dropdown lists unless an extension is included. The function dropdownList provide an alternative.
dropdownList(base, options, textvariable, width = 10, default, editable = FALSE) getListOption(targetWidget, options, height, vScroll = FALSE)
dropdownList(base, options, textvariable, width = 10, default, editable = FALSE) getListOption(targetWidget, options, height, vScroll = FALSE)
base |
|
options |
|
textvariable |
|
width |
|
default |
|
targetWidget |
|
editable |
|
height |
|
vScroll |
|
base
can be a top window or a frame.
The widget returns a frame that contains a dropdown list. The frame need to be placed using any of the layout methods of tcltk. The value of the selection will be accessed through the tclVar object passed to the function.
getListOptions is called by dropdown list to get the selected item
dropdownList returns a tkwin object for the frame that contains a dropdown list
getListOptions returns a character string for the selected item
Jianhua Zhang
tcltk
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded base <- tktoplevel() selection <- tclVar() dropdownList(base, c("Option 1", "Option 2", "Option 3"), selection, 15, "Option 2") tclvalue(selection) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded base <- tktoplevel() selection <- tclVar() dropdownList(base, c("Option 1", "Option 2", "Option 3"), selection, 15, "Option 2") tclvalue(selection) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
This function associates a tk listbox with a scroll bar and then puts them into a given tk widget.
makeViewer(target, vWidth = "", vHeight = "", hScroll = FALSE, vScroll = TRUE, what = "list", side = "left", text = "")
makeViewer(target, vWidth = "", vHeight = "", hScroll = FALSE, vScroll = TRUE, what = "list", side = "left", text = "")
target |
tk widget that can accommodate a list box. |
vWidth , vHeight
|
integers giving width and height of the listbox. |
hScroll , vScroll
|
logicals indicating whether a horizontal or vertical scroll bar should be associated with the list box. |
what |
A character string indicating the type of the viewer to be put on a widget. Valid types include "list" for list box, "canvas", and "text" for text box |
side |
A character string for the geometry management of the viewer on the widget. Valid values include "left", "right", "top", and "bottom" |
text |
A character string to be displayed |
Tk list boxes (or canvas, text box) and scroll bars are separate widgets. This function provides a common interface to put them together and functionally associated.
This function does not return any value.
Jianhua (John) Zhang
tklistbox
(from the ‘tcltk’
package).
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded # Create a top level window and put a list box in it base <- tktoplevel() listBox <- makeViewer(base) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded # Create a top level window and put a list box in it base <- tktoplevel() listBox <- makeViewer(base) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
This function creates a group of list boxes what share a common vertical scroll bar. Values in all the list boxes scroll up or down when the scroll bar is dragged
oneVScrList(base, data)
oneVScrList(base, data)
base |
|
data |
|
The matrix should have names for its columns. The names of the list boxes to be created will be the same as the corresponding columns of the matrix.
Data in the list boxes can be sorted based on values in any of the list boxes.
This function returns a list containing the tkwin objects of the list boxes created.
Jianhua Zhang
tcltk
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded testData <- matrix(c(1:50, 100:51), ncol = 2) colnames(testData) <- c("Column 1", "Column 2") base <- tktoplevel() tt <- oneVScrList(base, testData) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded testData <- matrix(c(1:50, 100:51), ncol = 2) colnames(testData) <- c("Column 1", "Column 2") base <- tktoplevel() tt <- oneVScrList(base, testData) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
This function checks to see if a given file name exists. If so, the function returns a connection to the file. Otherwise, it returns "fileName doest exist".
safeFileOpen(fileName)
safeFileOpen(fileName)
fileName |
|
When this function is used, users have to make sure to check to see if the returnd object inherits object "connection". Otherwise, the file doest not exist or a connection has not be made.
The function returns a connection object that inherits class "connection" if the file exists and is opend. Otherwise, the string "fileName doest not exist"
This function is no placed here to be used by various widgets. May be mored to a more suitable place later
Jianhua Zhang
write("A test file", "testFile4safeFileOpen") tt <- safeFileOpen("testFile4safeFileOpen") inherits(tt, "connection") unlink("testFile4safeFileOpen") tt <- safeFileOpen("testFile4safeFileOpen") inherits(tt, "connection")
write("A test file", "testFile4safeFileOpen") tt <- safeFileOpen("testFile4safeFileOpen") inherits(tt, "connection") unlink("testFile4safeFileOpen") tt <- safeFileOpen("testFile4safeFileOpen") inherits(tt, "connection")
Current tcltk library does not support tooltip unless an extension is included. The function tooltip is implemented as an alternative.
tooltip(text, targetWidget, width = 350)
tooltip(text, targetWidget, width = 350)
text |
|
targetWidget |
|
width |
|
Given a target tcltk widget, a tooltip will be associated with the widget. The content of the tooltip will be shown when mouse moves over the widget and disappear when mouse moves out of the widget.
This function returns invisible()
Jianhua Zhang
tcltk
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded base <- tktoplevel() but <- tkbutton(base, text = "Move Mouse Over Me") tkpack(but) tkbind(but, "<Enter>", expression(tooltip("Move mouse off me", but))) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded base <- tktoplevel() but <- tkbutton(base, text = "Move Mouse Over Me") tkpack(but) tkbind(but, "<Enter>", expression(tooltip("Move mouse off me", but))) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
This class takes a list of primary widgets and then creates a "widgetView" object that renders the primary widgets
Objects can be created by calls of the form new("widget", ...)
.
wTitle
:Object of class "character"
- a
character string for the title of the widget to be created
pWidgets
:Object of class "list"
- a list of
"basicPW" objects representing widget elements to be rendered
env
:Object of class "environment"
- an R
environment for the object to work within
funs
:Object of class "list"
- a list of
functions that will be associated with buttons on the widget to be
rendered. The name of the function in the list will be the text
appears on the button and the function will be executed when the
button is pressed
preFun
:Object of class "function"
- a function
that will be executed before the widget is constructed
postFun
:Object of class "function"
- a function
that will be executed before the widget is destroyed
signature(object = "widget")
: set the value for env
signature(object = "widget")
: get the value for env
signature(object = "widget")
: set the value for
funs
signature(object = "widget")
: get the value for funs
signature(object = "widget")
: set the value
for postFuns
signature(object = "widget")
: get the value
for postFuns
signature(object = "widget")
: set the value
for preFun
signature(object = "widget")
: get the value for
preFun
signature(object = "widget")
: set the value
for pWidgets
signature(object = "widget")
: get the value
for pWidgets
signature(object = "widget")
: update the
value of check buttons of the widget to be rendered
signature(object = "widget")
: update the
value of list box/entry of the widget to be rendered
signature(object = "widget")
: update the
value of radio buttons of the widget to be rendered
signature(object = "widget")
: update the
value of text box of the widget to be rendered
signature(object = "widget")
: set the value
of wTitle
signature(object = "widget")
: get the value of
wTitle
Jianhua Zhang
Programming with data
basicPW-class
, widgetView-class
PWEnv <- new.env(hash = TRUE, parent = parent.frame(1)) label1 <- label(wName = "label1", wValue = "File Name: ", wEnv = PWEnv) entry1 <- entryBox(wName = "entry1", wValue = "Feed me using browse", wEnv = PWEnv) browse2Entry1 <- function(){ tempValue <- fileBrowser() temp <- get(wName(entry1), wEnv = 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) list1 <- listBox(wName = "list1", wValue = c(Option1 = TRUE, Option2 = FALSE, Option3 = FALSE), wEnv = PWEnv) text1 <- textBox(wName = "text1", wValue = "Feed me something", wEnv = PWEnv) label2 <- label(wName = "label2", wValue = "Select one: ", wEnv = PWEnv) radios1 <- radioButton(wName = "radios1", wValue = c(radio1 = TRUE, radio2 = FALSE, radio3 = FALSE), wEnv = PWEnv) 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) 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)
PWEnv <- new.env(hash = TRUE, parent = parent.frame(1)) label1 <- label(wName = "label1", wValue = "File Name: ", wEnv = PWEnv) entry1 <- entryBox(wName = "entry1", wValue = "Feed me using browse", wEnv = PWEnv) browse2Entry1 <- function(){ tempValue <- fileBrowser() temp <- get(wName(entry1), wEnv = 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) list1 <- listBox(wName = "list1", wValue = c(Option1 = TRUE, Option2 = FALSE, Option3 = FALSE), wEnv = PWEnv) text1 <- textBox(wName = "text1", wValue = "Feed me something", wEnv = PWEnv) label2 <- label(wName = "label2", wValue = "Select one: ", wEnv = PWEnv) radios1 <- radioButton(wName = "radios1", wValue = c(radio1 = TRUE, radio2 = FALSE, radio3 = FALSE), wEnv = PWEnv) 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) 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)
"widgetView" renders element widgets
Objects can be created by calls of the form new("widgetView",
...)
. This class is for internal use by class
widget-class
. Users trying to create GUI type widget do
not need to use this class.
WVTitle
:Object of class "character"
- a
character string that will be displayed as the title of the widget
to be created
vName
:Object of class "character"
- a character
string for the vName of the widget
winid
:Object of class "tkwin"
- a tkwin object
for the id of the top window for the widget
widgetids
:Object of class "list"
- a list of
tkwin ids for element widgets
theWidget
:Object of class "widget"
- a widget
object that creates the widgetView
signature(tkWidget = "widgetView")
: destroys
the window representing the widgetView
signature(object = "widgetView")
: set the value
for vName
signature(object = "widgetView")
: get the value
for vName
signature(widgetView = "widgetView",
pWidgets = "list")
: takes a list of "basicPW" objects
(pWidgets) and renders them accordingly
signature(widgetView = "widgetView", pWidgets
= "list")
: using values contained by the "basicPW" objects of
pWidgets to update the values of widget elements displayed
signature(object = "widgetView")
: set the
value for theWidget
signature(object = "widgetView")
: get the
value for theWidget
signature(widgetView = "widgetView")
:
update the value of list box or text box element widgets
signature(object = "widgetView")
: set the
value of widgetids
signature(object = "widgetView")
: get the
value of widgetids
signature(object = "widgetView")
: set the
value of winid
signature(object = "widgetView")
: set the value
of winid
signature(tkWidget = "widgetView")
: make
widgetView modal
signature(object = "widgetView")
: get the
value for WVTitle
Jianhua Zhang
Programming with data
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded widgetView <- widgetView(WVTitle = "demo", vName = "widget1") ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded widgetView <- widgetView(WVTitle = "demo", vName = "widget1") ## End(Not run)
These functions provide some of the common read and write operations for tcltk widgets
writeText(widget, value, clear = TRUE) writeList(widget, value, clear = TRUE) getListValue(which) getTextValue(which) getEntryValue(which)
writeText(widget, value, clear = TRUE) writeList(widget, value, clear = TRUE) getListValue(which) getTextValue(which) getEntryValue(which)
widget |
|
value |
|
clear |
|
which |
|
writeText
writes to a given tcltk text box widget.
writeList
writes to a given tcltk list or entry box
widget.
getListValue
retrieves the selected value in a tcltk
list widget.
getTextValue
retrieves the value of a text box.
getEntryValue
retrieves the value of an entry box.
getListValue
returns the selected value in a tcltk
list widget.
getTextValue
returns the value of a text box.
getEntryValue
returns the value of an entry box.
Jianhua Zhang
R tcltk
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded # Create the widgets base <- tktoplevel() list <- tklistbox(base, width = 20, height = 5) entry <- tkentry(base) text <- tktext(base, width = 20, height = 5) tkpack(list, entry, text) # Write and read from the widgets writeList(list, c("Option1", "Option2", "Option3")) writeList(entry, "An Entry box") writeText(text, "A text box") # Will be NULL if not selected getListValue(list) getTextValue(text) getEntryValue(entry) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)
## Not run: ## These cannot be run by examples() but should be OK when pasted ## into an interactive R session with the widgetTools package loaded # Create the widgets base <- tktoplevel() list <- tklistbox(base, width = 20, height = 5) entry <- tkentry(base) text <- tktext(base, width = 20, height = 5) tkpack(list, entry, text) # Write and read from the widgets writeList(list, c("Option1", "Option2", "Option3")) writeList(entry, "An Entry box") writeText(text, "A text box") # Will be NULL if not selected getListValue(list) getTextValue(text) getEntryValue(entry) # Destroy toplevel widget # tkdestroy(base) ## End(Not run)