gnotebook {gWidgets} | R Documentation

## constructor for notebook widget

### Description

A notebook widget organizes different pages using tabs, allowing only one page to be shown at once. Clicking on the tab raises the associated page.

### Usage

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

### Arguments

`tab.pos` | Where to place tabs (1 bottom, 2 left side, 3 top, 4 right side
`closebuttons` | Is there a close button in the tab?
`dontCloseThese` | If `closebuttons=TRUE` this will make it impossible to remove these tabs. Specified by tab number
`container` | Optional parent container to attach notebook widget to
`...` | passed to `add` method of parent container
`toolkit` | Which GUI toolkit to use

### Details

In what follows, it is useful to think of a notebook as a vector with named entries, each entry being a widget, the name being the tab label.

Notebooks have the following methods:

New pages are added with the `add` method, which most likely is called by the widget constructor. The extra argument `label` is used to specify the tab label. This may be a string, or in gWidgetsRGtk2 a `glabel` instance. The extra argument `index` can be used to specify which page to add to. By default, a new page is created at the end of the notebook. In gWidgetsRGtk2, the extra argument `override.closebutton` can be used to add or not add a close button in the tab label.

The `svalue` method returns the current page number. The `svalue<-` method is used to set the page number.

The `dispose` method will remove the currently selected page unless it is overridden by the value of `dontCloseThese`.

The `delete(obj, widget,...)` method will delete the widget on a given page. For some toolkits, the unparented widget can be reparented with the `add` method or `[<-`.

The `length` method returns the number of pages.

The `names` method returns the tab labels.

The `names<-` method may be used to replace the tab labels. Something like `names(obj)[1]<-"new label"` should work.

The `"["` method refers to the widgets in the notebook. It returns a single widget or list of widgets.

For some toolkits, the `"[<-"` method may be used to replace a widget on a notebook page.

The `addHandlerChanged` method passes the component `pageno` when the page index returned by `svalue` within the handler refers to the tab before it was changed. The following could be used to get the right one in a portable way: `if(is.null(h$pageno)) svalue(h$obj) else h$pageno`

### See Also

See `gwindow` for top-level containers, `ggroup`, `gframe` and `gexpandgroup` for box containers

### Examples

    ## Not run:
      w <- gwindow("gnotebook example")
      nb <- gnotebook(container=w)
      ## "add" called by constructor
      glabel("Widget 1", container=nb, label="page 1")
      ## label argument passed by constructor to add method
      glabel("Widget 2", container=nb, label="page 2")

      length(nb)
      names(nb)
      names(nb)[1] <- "Page 1"

      svalue(nb) <- 2
      dispose(nb) ## dispose current tab
      length(nb)

    ## End(Not run)

[Package gWidgets version 0.0-54.2 Index]