Copyright © tutorialspoint.com

Ruby/Tk - Paned Windows Widget

previous next


The Panedwindow widget lets you stack two or more resizable widgets above and below each other (or to the left and right).

The user can adjust the relative heights (or widths) of each pane by dragging a sash located between them. Typically the widgets you're adding to a panedwindow will be frames containing many other widgets.

Syntax:

Here is a simple syntax to create this widget:

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

Standard Options:

Widget-specific Options:

SNOptions with Description
1orient => String
One of horizontal or vertical. Specifies the orientation of the separator.
2width => Integer
If present and greater than zero, specifies the desired width of the widget in pixels. Otherwise, the requested width is determined by the width of the managed windows.
3height => Integer
If present and greater than zero, specifies the desired height of the widget in pixels. Otherwise, the requested height is determined by the height of the managed windows.

Manipulating Paned

Examples:

require 'tk'
require 'tkextlib/tile'

$resultsVar = TkVariable.new
root = TkRoot.new
root.title = "Window"

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

f1 = TkFrame.new(p) {
  relief 'groove'
  borderwidth 3
  background "red"
  padx 30
  pady 30
  pack('side' => 'left', 'pady' => 100)
}
f2 = TkFrame.new (p){
  relief 'groove'
  borderwidth 3
  background "yellow"
  padx 30
  pady 30
  pack('side' => 'right', 'pady' => 100)
}

p.add f1, nil
p.add f2, nil

Tk.mainloop

This will produce following result

Ruby/Tk paned

previous next

Copyright © tutorialspoint.com