Free Access Week - Data Engineering + BI
Data engineering and BI courses are free!
Free Access Week - Jun 2-8

traitr (version 0.13)

buttonItem: Button item to initiate an action...

Description

Button item to initiate an action

Usage

buttonItem(value="button label", action, name, label=name, help="",
    tooltip="", attr, model, editor, ...)

Arguments

value
Default value for the model
action
function to call when clicked. Signature is function(., h, ...) {} (like gWidgets with extra leading .). The "." is the button item, not the itemgroup or dialog that this item may be a part of. When that is the case
name
Required name for object. Names should be unique within a group of items
label
Optional label, default value is the name. Use "" to have not label text.
help
Optional help string
tooltip
Optional tooltip to display
attr
A list of attributes to pass to widget on construction. Eg. attr=list(size=c(100,200))
model
Optional model. Useful if one wishes to use same model for multiple views
editor
Specification of editor (a view) to override default
...
Passed to parent proto object during call to proto

Value

  • A proto object. Call obj$show_help() to view its methods and properties.

Details

While dialogs have a buttons property for the main buttons, this item allows other buttons to be used within a dialog. One must define an action (a callback) to call when the button is clicked. There are some issues with how this method is defined and where it is evaluated.

See Also

Item

Examples

Run this code
## basic button. Note the extra "." compared to gWidgets handler
b <- buttonItem("click me", action=function(.,h,...) {
print("hi")

})
## An example within a dialog
dlg <- aDialog(items=list(
a = stringItem(""),
b = buttonItem("Click me", label="", action=function(., h, ...) {
galert(sprintf("Item a is %s
", .$parent$get_a()))
})
),
title="A dialog with a button item",
buttons=c()               # no standard buttons
)
dlg$make_gui()

Run the code above in your browser using DataLab