Q: How do I

G

Guido de Melo

Hallo ruby users,

I' writing a tool to display bibliographical data in columns and I want to
employ glade for the first time. My display gets built with the source
below, but I don't get any columns. Can someone please comment?

Thanks
Guido


#!/usr/bin/ruby

require 'libglade2'

class Rbib
def initialize(path)
@glade = GladeXML.new(path) {|handler| method(handler)}
@view = @glade.get_widget("treeview1")
# key, title, name, year, rank, category
@liststore = Gtk::ListStore.new(String, String, String, String, String, String, String)
iter = @liststore.append
iter[0] = "key"
iter[1] = "title"
iter[2] = "name"
iter[3] = "year"
iter[4] = "rank"
iter[5] = "category"

%w{key title name year rank category}.each_with_index do |title, i|
col = Gtk::TreeViewColumn.new(title, Gtk::CellRendererText.new, {:text => 0})
@view.append_column(col)
end
end

# just do simple stuff for now
def on_quit
Gtk.main_quit
end
end

Gnome::program.new("test", "0.1")
Rbib.new(File.dirname($0) + "/test.glade")
Gtk.main
 
L

Laurent Sansonetti

Hi,

Hallo ruby users,
=20
I' writing a tool to display bibliographical data in columns and I want t= o
employ glade for the first time. My display gets built with the source
below, but I don't get any columns. Can someone please comment?
=20
Thanks
Guido
=20
#!/usr/bin/ruby
=20
require 'libglade2'
=20
class Rbib
def initialize(path)
@glade =3D GladeXML.new(path) {|handler| method(handler)}
@view =3D @glade.get_widget("treeview1")
# key, title, name, year, rank, category
@liststore =3D Gtk::ListStore.new(String, String, String, String, Str= ing, String, String)
iter =3D @liststore.append
iter[0] =3D "key"
iter[1] =3D "title"
iter[2] =3D "name"
iter[3] =3D "year"
iter[4] =3D "rank"
iter[5] =3D "category"
=20

You seem to forgot to plug your model (liststore) in the view there.
%w{key title name year rank category}.each_with_index do |title, i|
col =3D Gtk::TreeViewColumn.new(title, Gtk::CellRendererText.new, {=
:text =3D> 0})
=20
^^^^^^^^^^

I believe you meant

:text =3D> 1
@view.append_column(col)
end
end
=20
# just do simple stuff for now
def on_quit
Gtk.main_quit
end
end
=20
Gnome::program.new("test", "0.1")
Rbib.new(File.dirname($0) + "/test.glade")
Gtk.main
=20
=20

This is the best I can do without seeing the .glade file. If these
changes do not work please post your .glade file :)

Laurent
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top