Gtk - Image via HTTP in TreeView

M

Michael Gebhart

Hi there,

I'm just writing my first ruby-gtk application. But already there are the
first problems :)

In my application I have a treeview with 2 columns. In the second column,
I wanna display some text, that works. In the first column I'm trying to
display an image. It should be a image from an external server. So first I
have to grab the image, but how should I do that? After that I have to
display it in the treeview, but this also doesn't work. Here are my first
tries:


@treeview = @glade.get_widget("treeview")

@treestore = Gtk::TreeStore.new(Gdk::pixbuf, String)
@treeview.model = @treestore

@renderer = Gtk::CellRendererText.new

col = Gtk::TreeViewColumn.new("Image", @renderer, nil)
@treeview.append_column(col)

col = Gtk::TreeViewColumn.new("Description", @renderer, :text => 0)
#What is the :text => for? I know, that are attributes. But what can I set
here?

@treeview.append_column(col)


#Inserting an element

newStore = @treestore.append(nil)
newStore[0] = Gtk::Image.new("http://myurl/meinpicture.png")
newStore[1] = "test"


This does not work. Any ideas?


Greetings

Mike
 
M

Masao Mutoh

Hi,

Hi there,

I'm just writing my first ruby-gtk application. But already there are the
first problems :)

In my application I have a treeview with 2 columns. In the second column,
I wanna display some text, that works. In the first column I'm trying to
display an image. It should be a image from an external server. So first I
have to grab the image, but how should I do that? After that I have to
display it in the treeview, but this also doesn't work. Here are my first
tries:

Use Gtk::CellRendererPixbuf to render pixbuf.

Try gtk/sample/misc/treeview.rb.
col = Gtk::TreeViewColumn.new("Description", @renderer, :text => 0)
#What is the :text => for? I know, that are attributes. But what can I set
here?

The column of the store. In this case, 0 means Gdk::pixbuf, 1 means String.

Read "Ruby/GTK TreeView Tutorial", please.
http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top