How to implement a grid view?

Hi,

I would like to have a grid view like excel which I can use the
cell(col,row) to access and change the value(text and bgcolor). Anyone
has some sample for me? I know the treeview can solve this problem but
it is too complex for me and I just want a simple grid view like excel.

For now, I only can think to write a model class for the treeview that
can be access using the row, column. But how do I initialize the col,
row model is still fuzzy for me. I am still new to gtk also.

Or may be a model like this:
col, row, text, bgcolor #model header
0, 0, ‘text’, ‘blue’
0, 1, ‘another’, ‘yellow’
1, 0, ‘blah’, ‘blue’
1, 1, ‘hello’, ‘red’

In this case, how do I access it specific cell using the cell(row,
column)? Need to iterate all the row until it match the col, row? seems
uneffective for me.

thanks in advance

Regards,
Shin Guey

I am not sure whether this specifically is possible.
Maybe have a look at Gnumeric to get a hint on how this could be done in
ruby-gtk (if you are not afraid to dig into C).

Personally I think using a Table might be the best compromise (it
probably does not suffice your use case though)

Marc H. wrote:

I am not sure whether this specifically is possible.
Maybe have a look at Gnumeric to get a hint on how this could be done in
ruby-gtk (if you are not afraid to dig into C).

I just take a look at Gnumeric. It is great but overkill for my need. I
wonder how they implement it using TreeView or they are not using
TreeView but customize widget? I will take a look later.

Personally I think using a Table might be the best compromise (it
probably does not suffice your use case though)

Yes, I was thinking to use Table but in some case I need a grid with
14000+ row, then I am sure using Table is not suitable.

thanks for the reply. Hopefully someone can help me on this.

Am Dienstag, den 18.03.2008, 02:44 +0100 schrieb Shin guey Wong:

Hi,

If you want to use the TreeView, your model should be a Gtk::ListStore.

A single cell you can access with Gtk::TreeIter.get_value and
Gtk::TreeIter.set_value.

If it’s possible to set the background to each cell indipendently i
don’t know.

To learn more about the TreeView read this:
http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview

An other option is to use Gtk::Sheet from GtkExtra (gtkextra.sf.net).
That is a real sheet like the one in a spreatsheet. The down sides are,
that you have to create ruby bindings on your own (that is fun :slight_smile: ) and
that the project seem to be near dead.

Cheers, detlef

Detlef R. wrote:

An other option is to use Gtk::Sheet from GtkExtra (gtkextra.sf.net).
That is a real sheet like the one in a spreatsheet. The down sides are,
that you have to create ruby bindings on your own (that is fun :slight_smile: ) and
that the project seem to be near dead.

Cheers, detlef

thanks.
Hmm, I never create any GTK widget binding for ruby before. I only
created a c-extension for ruby before. I will take a look and see
whether I can do it or not and how much time to take. BTW, I am working
on windows platform and I am not sure the Gtk::Sheet will be working on
windows or not. :frowning:

Shin guey Wong wrote:

BTW, I am working
on windows platform and I am not sure the Gtk::Sheet will be working on
windows or not. :frowning:

There is a win32 port for the extra libraries: