Constructors for label widget

Share:

Description

This constructor produces a widget to display a line or multipline lines of text.

For some toolkits, the text can be marked up.

An option is available so that the displayed text can be edited.

Usage

1
2
glabel(text = "", markup = FALSE, editable = FALSE, handler = NULL,
action = NULL, container = NULL, ..., toolkit = guiToolkit())

Arguments

text

Text to show in the label or button. For buttons, if this text matches a stock icon name, an icon is shown as well

markup

Logical indicating if text for a label uses markup

editable

Logical. If TRUE, then the label's text can be set by clicking on the label and filling in the edit box.

handler

Handler called on a click event

action

Passed to handler

container

Optional container to attach widget to.

...

Passed to add method of container

toolkit

Which GUI toolkit to use

Details

The svalue() method returns the value of the widget. For a label, this is the text as a single string (which may not include a "\n" for newlines if not supported by the toolkit).

The svalue<-() method can be used to set the value of the widget. For labels and buttons, value with length greater than one are pasted together collapsed with "\n".

The addhandlerclicked method specifies a handler to be called on click events.

Although in some toolkits, labels are meant to hold static text, gWidgets treats label widgets like other widgets allowing the user to bind handlers to mouse clicks. For labels, if editable=TRUE is specified, clicking on the text allows one to edit the label's value overriding the click handler in the process. However, the addhandlerchanged handler can be given to respond to the text after it has been chnaged.

Examples

1
2
3
4
5
6
7
## Not run: 
   glabel("a label", container=TRUE)
   glabel("Click me to edit label", editable=TRUE, container=TRUE)
   glabel("Click me for a message", container=TRUE,
   handler=function(h,...) {cat("Hi\n")})

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.