Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gnotebook

Constructor for a tabbed notebook container


Description

The tabbed notebook container allows one to hold many different pages with a mechanism – tabs – to switch between them. In gWidgets2 new pages are added through the add method. This is usually called implicitly in the child object's constructor. One passes in the tab label through the extra label argument. Labels may be subsequently changed through names<-.

generic for toolkit dispatch

Children added to notebooks need a label, a position and optionally a close button (if supported). The arguments expand, fill, anchor are not specified – children expand and fill the allocated space.

Dispose deletes the current page, not the entire notebook object. To delete a specific page, a combination of svalue<- and dispose may be used.

The names of a notebook are the page tab labels. These may be retrieved and set through the names method.

The notebook object contains pages referenced by index. This allows access to underlying page.

The change handler for the notebook is called when the page changes. Tthe new page number is passed back in the page.no component of 'h', which in some cases may differ from the value given by svalue within the handler call.

Dispose deletes the current page, not the entire notebook object. To delete a specific page, a combination of svalue<- and dispose may be used.

Usage

gnotebook(tab.pos = 3, container = NULL, ..., toolkit = guiToolkit())

.gnotebook(toolkit, tab.pos = 3, container = NULL, ...)

## S3 method for class 'GNotebook'
add(obj, child, expand, fill, anchor, ...)

## S3 method for class 'GNotebook'
dispose(obj, ...)

## S3 method for class 'GNotebook'
names(x)

## S3 replacement method for class 'GNotebook'
 svalue(obj, index=TRUE, ...) <- value

## S3 method for class 'GNotebook'
x[i, j, ..., drop = TRUE]

## S3 method for class 'GNotebook'
addHandlerChanged(obj, handler, action = NULL, ...)

## S3 method for class 'GStackWidget'
dispose(obj, ...)

Arguments

tab.pos

integer. Position of tabs, 1 on bottom, 2 left, 3 top, 4 right. (If supported)

container

parent container

...

passed to add method for container

toolkit

underlying toolkit

obj

gnotebook object

child

some child component to add

expand

NULL or logical. For box containers controls whether a child will expand to fill the allocated space.

fill

NULL or character. For box containers. The value of fill (not always respected) is used to control if expansion happens vertically (y), horizontally (x) or both (both or TRUE). For vertically filled box containers, children always fill horizontally (atleast) and for horizontally filled box containers, children always fill vertically (atleast). This is important to realize when trying to size buttons, say.

anchor

NULL or integer. For box containers. The anchor argument is used to position the child within the parent when there is more space allocated than the child requests. This is specified with a Cartesian pair in -1,0,1 x -1, 0, 1.

x

notebook object svalue method

Set the currently raised tab by index (the default) or name

index

TRUE refer to tab by 1-based index; FALSE allows reference by tab label.

value

assignment value

i

row index. Either integer or character

j

ignored

drop

ignored

handler

handler

action

passed along to handler via h[["action"]].

Value

none. called for its side effect.

Note

In gWidgets2 the button arguments of the gWidgets constructor are removed. One passes the close button request to the add method.

To keep the signature the same as the generic, several arguments are passed in via ...:

label

A character. Label text for tab

i

An integer in 0 to length(obj) indicating the position to insert child. The new page is inserted to the right of page number i. When i=0, the page appears at the front, when i is not specified it appears at the end.

close.button

A logical. If TRUE – and the toolkit supports it – the page tab will include a close button.

See Also

gstackwidget for a similar widget without tabs.

Examples

## Not run: 

w <- gwindow("notebook example", visible=FALSE)
nb <- gnotebook(container=w)
gbutton("Page one", label="tab 1", container=nb) ## note label argument
gbutton("Page two", label="tab 2", container=nb)
svalue(nb) <- 1
addHandlerChanged(nb, handler=function(h,...) {
  message(sprintf("On page %s", h$page.no)) ## svalue(h$obj) not always right
})
svalue(nb) <- 2 ## or use "Page two"
dispose(nb)
length(nb)


## End(Not run)

gWidgets2

Rewrite of gWidgets API for Simplified GUI Construction

v1.0-8
GPL (>= 3)
Authors
John Verzani
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.