Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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. – RobotHumans 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
    
    
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.