ruby gnome2 - stuck with combo box

P

prhlava

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
 
N

Norman Smith

prhlava said:
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
 
P

prhlava

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top