- Ruby Basics
- Ruby - Home
- Ruby - Overview
- Ruby - Environment Setup
- Ruby - Syntax
- Ruby - Classes and Objects
- Ruby - Variables
- Ruby - Operators
- Ruby - Comments
- Ruby - IF...ELSE
- Ruby - Loops
- Ruby - Methods
- Ruby - Blocks
- Ruby - Modules
- Ruby - Strings
- Ruby - Arrays
- Ruby - Hashes
- Ruby - Date & Time
- Ruby - Ranges
- Ruby - Iterators
- Ruby - File I/O
- Ruby - Exceptions
- Ruby Advanced
- Ruby - Object Oriented
- Ruby - Regular Expressions
- Ruby - Database Access
- Ruby - Web Applications
- Ruby - Sending Email
- Ruby - Socket Programming
- Ruby - Ruby/XML, XSLT
- Ruby - Web Services
- Ruby - Tk Guide
- Ruby - Ruby/LDAP Tutorial
- Ruby - Multithreading
- Ruby - Built-in Functions
- Ruby - Predefined Variables
- Ruby - Predefined Constants
- Ruby - Associated Tools
- Ruby Useful Resources
- Ruby - Quick Guide
- Ruby - Useful Resources
- Ruby - Discussion
- Ruby - Ruby on Rails Tutorial
Ruby/TK - Paned Windows Widget
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
- class
- cursor
- style
- takefocus
Widget Specific Options
Sr.No. | Options & Description |
---|---|
1 | orient => String One of horizontal or vertical. Specifies the orientation of the separator. |
2 | width => 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. |
3 | height => 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
Calling the "add" method will add a new pane at the end of the list of panes. The "insert position subwindow" method allows you to place the pane at the given position in the list of panes (0..n-1); if the pane is already managed by the panedwindow, it will be moved to the new position. You can use the "forget subwindow" to remove a pane from the panedwindow; you can also pass a position instead of a subwindow.
Other options let you sign relative weights to each pane so that if the overall panedwindow resizes, certain panes will get more space than others. As well, you can adjust the position of each sash between items in the panedwindow. See the command reference for details.
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 the following result −
To Continue Learning Please Login
Login with Google