CList widget
Gtk::CList is a multi-column list widget. It will replace Gtk::List class
(of course, Gtk::List is still available).
ex: Display Environmental Variables
nn
Here is the simple example of CList class.
This program displayes all environmental variables.
Program clist.rb:
require 'gtk'
window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
clist = Gtk::CList.new(['name', 'value'])
clist.set_usize(300, 200)
clist.set_column_width 0, 100
ENV.keys.sort.each {|k| clist.append [k, ENV[k]]}
window.add clist
clist.show
window.show
Gtk.main
Result:
(attention: this result depends gtk-1.0.x. If you execute this program
with version 1.2.x, little changes will be occur in look & feel.)
Description:
clist = Gtk::CList.new(['name', 'value'])
This creates a 2 columns CList widget object, which titles are
'name' and 'value'.
clist.set_usize(300, 200)
This set the widget 300 pixels width, 200 pixels height.
clist.set_column_width 0, 100
This set the first column 100 pixels width.
The index of the first column is 0.
ENV.keys.sort.each {|k| clist.append [k, ENV[k]]}
"ENV" is built-in constant of Ruby. It is (pseudo) Hash which contains
environment variable.
This adds the pair of one variable name and its value to list.
The length of array for "append" method must be equal to the number of
CList columns.
Methods of CList Widget
Gtk::CList.new
(columns)
Gtk::CList.new
(['title1', 'title2', ... ])
-
This method creates a CList widget.
When using first style, created CList have "columns" columns but no title.
When using second style, created CList have columns with title.
set_policy
(vscrollbar_policy, hscrollbar_polic
y)
Next
[TOP]
Written by
akaishi@ruby.freak.ne.jp