Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Q: How do I

Reply
Thread Tools

Q: How do I

 
 
Guido de Melo
Guest
Posts: n/a
 
      05-11-2005
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:rogram.new("test", "0.1")
Rbib.new(File.dirname($0) + "/test.glade")
Gtk.main

 
Reply With Quote
 
 
 
 
Laurent Sansonetti
Guest
Posts: n/a
 
      05-11-2005
Hi,

On 5/11/05, Guido de Melo <> wrote:
> 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:rogram.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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57