Ruby gnome2 - stuck with combo box

hello,

i am trying to create a combo box where drop-down bit is a list-store
with two columns. the following code does not work:

@title = Gtk::ComboBox.new(false)
renderer = Gtk::CellRendererText.new()
@title.append_column(Gtk::TreeViewColumn.new(‘id’, renderer, :text =>
0))
@title.append_column(Gtk::TreeViewColumn.new(‘name’, renderer, :text =>
1))

(the append_column method does not exist).

i have searched the documentation but still cannot figure this one out
(it works with tree views).

did i miss some part of documentation?

vlad

prhlava wrote:

hello,

i am trying to create a combo box where drop-down bit is a list-store
with two columns. the following code does not work:

@title = Gtk::ComboBox.new(false)
renderer = Gtk::CellRendererText.new()
@title.append_column(Gtk::TreeViewColumn.new(‘id’, renderer, :text =>
0))
@title.append_column(Gtk::TreeViewColumn.new(‘name’, renderer, :text =>
1))

(the append_column method does not exist).

i have searched the documentation but still cannot figure this one out
(it works with tree views).

did i miss some part of documentation?

vlad

See sample code in combo.rb in ruby gnome
distribution directory
…/ruby-gnome…/gtk/sample/misc

The following is a simple example.

require “gtk2”

window = Gtk::Window.new(“Gtk::ComboBox Title”)
window.signal_connect(“destroy”){Gtk.main_quit}

model = Gtk::ListStore.new(String,String)
[[“ID1:”,“J. J. Calhoun”],[“ID2:”,“Hans C. Nirbert”]].each {|id,name|
iter = model.append
iter[0] = id
iter[1] = name
}
title = Gtk::ComboBox.new(model)
renderer = Gtk::CellRendererText.new
title.pack_start(renderer,false)
title.set_attributes(renderer, :text => 0)
renderer = Gtk::CellRendererText.new
title.pack_start(renderer,false)
title.set_attributes(renderer, :text => 1)

vbox = Gtk::VBox.new
vbox.add(title)
window.add(vbox).show_all
Gtk.main

good luck

See sample code in combo.rb in ruby gnome
distribution directory
…/ruby-gnome…/gtk/sample/misc

The following is a simple example.

thank you very much, it works now…

vlad

ps: i will read examples, i will read examples, i will read examples, i
will read examples, i will read examples, i will read examples, i will
read examples, i will read examples, i will read examples, i will read
examples, i will read examples, i will read examples, i will read
examples, i will read examples, i will read examples, i will read
examples, i will read examples, i will read examples, i will read
examples, i will read examples, i will read examples, i will read
examples, i will read examples, i will read examples, i will read
examples…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs