The tabbed notebook widget

The tabbed notebook widget

James Wettenhall & Philippe Grosjean bio photo By James Wettenhall & Philippe Grosjean

The R code below creates a window with two tabs (with a label in the first one and a button in the second one):


win1 <- tktoplevel()

# Create two tabs
win1$env$nb <- tk2notebook(win1, tabs = c("Test", "Button"))
tkpack(win1$env$nb, fill = "both", expand = TRUE)

# Populate these tabs with various widgets
win1$env$tb1 <- tk2notetab(win1$env$nb, "Test")
win1$env$lab <- tk2label(win1$env$tb1, text = "Nothing here.")

win1$env$tb2 <- tk2notetab(win1$env$nb, "Button")
win1$env$but <- tk2button(win1$env$tb2, text = "Click me",
  command = function() tkdestroy(win1))
# You can use a different manager than for the notebook
tkgrid(win1$env$but, padx = 50, pady = 30)

# Select a tab programmatically$env$nb, "Button")
tk2notetab.text(win1$env$nb) # Text of the currently selected tab
## [1] "Button"

notebook with the "Button" tab selected

notebook with the "Test" tab selected