Learn R Programming

gWidgets2 (version 1.0-9)

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<-.

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 GNotebook add(obj, child, expand, fill, anchor, ...)

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

# S3 method for GNotebook names(x)

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

# S3 method for GNotebook [(x, i, j, ..., drop = TRUE)

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

# S3 method for 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.

See Also

gstackwidget for a similar widget without tabs.

Examples

Run this code
# 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)

# }

Run the code above in your browser using DataLab