[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby gnome2 - stuck with combo box

prhlava

2/18/2007 1:51:00 PM


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
2 Answers

Norman Smith

2/18/2007 3:50:00 PM

0

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

--
Posted via http://www.ruby-....

prhlava

2/18/2007 4:41:00 PM

0

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