Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How do I add particular images which is situated in given url, in my app , can I do it in glade?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This works for me:

from gi.repository import Gtk

class Handler:
    def on_window1_delete_event(self, *args):
        Gtk.main_quit(*args)

def change_image(image):
    the_image = builder.get_object("replaceimage")
    the_image.set_from_file(image)
    the_image.queue_draw()

builder = Gtk.Builder()
builder.add_from_file("ui/sample.glade")
builder.connect_signals(Handler())
window = builder.get_object("window1")
window.show_all()

change_image("assets/image.png")

Gtk.main()

It uses this glade file.

It does, however, require that you save the image to disk first.

share|improve this answer
    
Thanks But I mean programatically include an image from internet ,ie ,url can be changed during the execution of the program . –  Tachyons Jul 2 '12 at 18:19
    
This does that. You save the file from the url to /tmp or whatever, then drop that local disk location in to choose image. –  hbdgaf Jul 2 '12 at 18:21
    
thanks , how to download an image using python code ? should I use wget for it ? –  Tachyons Jul 2 '12 at 18:56
    
docs.python.org/library/urllib2.html –  hbdgaf Jul 2 '12 at 18:58
    
I tried urllib2.urlopen( image url) , but where is it stored ? –  Tachyons Jul 2 '12 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.