# Ruby gnome2 - stuck with combo box

**URL:** <https://www.ruby-forum.com/t/ruby-gnome2-stuck-with-combo-box/85977>\
**Category:** Ruby\
**Created:** [February 18, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/ruby-gnome2-stuck-with-combo-box/85977 "2007-02-18T14:55:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prhlava](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@prhlava](https://www.ruby-forum.com/u/prhlava)\
**Post date:** [February 18, 2007, 2:55pm UTC](https://www.ruby-forum.com/t/ruby-gnome2-stuck-with-combo-box/85977/1 "2007-02-18T14:55:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prhlava](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@prhlava](https://www.ruby-forum.com/u/prhlava)\
**Post date:** [February 18, 2007, 4:49pm UTC](https://www.ruby-forum.com/t/ruby-gnome2-stuck-with-combo-box/85977/2 "2007-02-18T16:49:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![prhlava](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@prhlava](https://www.ruby-forum.com/u/prhlava)\
**Post date:** [February 18, 2007, 5:45pm UTC](https://www.ruby-forum.com/t/ruby-gnome2-stuck-with-combo-box/85977/3 "2007-02-18T17:45:49Z")

</div>

> 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…
