Copyright © tutorialspoint.com

Ruby/Tk - Notebook Widget

previous next


The NoteBook widget provides a notebook metaphor to display several windows in limited space. The notebook is divided into a stack of pages of which only one is displayed at any time.

The other pages can be selected by means of choosing the visual tabs at the top of the widget. Additionally, the <Tab> key may be used to traverse the pages. If underline option is used, Alt-bindings will also work.

Syntax:

Here is a simple syntax to create this widget:

Tk::Tile::Notebook.new(root) {
  .....Standard Options....
  .....Widget Specific Options....
}

Standard Options:

Widget-specific Options:

SNOptions with Description
1height => Integer
If present and greater than zero, specifies the desired height of the pane area (not including internal padding or tabs). Otherwise, the maximum height of all panes is used.
2padding => Integer
Specifies the amount of extra space to add around the outside of the notebook. The padding is a list of up to four length specifications left top right bottom. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left.
3width => Integer
If present and greater than zero, specifies the desired width of the pane area (not including internal padding). Otherwise, the maximum width of all panes is used.

Manipulating Notebook:

There are various ways to play with Notebook:

Examples:

require 'tk'
require 'tkextlib/tile'

root = TkRoot.new
root.title = "Window"

n = Tk::Tile::Notebook.new(root)do
  height 110
  place('height' => 100, 'width' => 200, 'x' => 10, 'y' => 10)
end

f1 = TkFrame.new(n)
f2 = TkFrame.new(n)
f3 = TkFrame.new(n)

n.add f1, :text => 'One', :state =>'disabled'
n.add f2, :text => 'Two'
n.add f3, :text => 'Three'

Tk.mainloop

This will produce following result

Ruby/Tk notebook

previous next

Copyright © tutorialspoint.com