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.

i am having a problem with a Gtk.Image. I use the set_from_file() function to add the image to the Gtk.Image but the image is not displayed! Instead the broken icon is...

The image exist and i can open it with the default image viewer so its not corrupted.. I tried with Pixbuf also but i get the same result..

Any idea why the image appears corrupted and how to fix it?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Broken icon means that there is a problem with the path of the image you are trying to set.Your code is correct. It just can't find the image you want to use thus a broken image is displayed instead.

 image = gtk.Image()
    image.set_from_file("/home/your_username/path/to/your/image.png")

In order to prevent mistakes from wrong paths, I suggest browsing with Nautilus at the image you want to use, right click on it -> Properties - > Basic : Location

share|improve this answer
    
But the image exist, example: the image must be /tmp/tmplMJf2g/The_Breaker_NW_c77[a-team].cbr/The_Breaker_NW77_001.png so i cd into the folder chris@chris-Aspire-5732Z:~$ cd /tmp/tmplMJf2g/The_Breaker_NW_c77[a-team].cbr/ chris@chris-Aspire-5732Z:/tmp/tmplMJf2g/The_Breaker_NW_c77[a-team].cbr$ ls The_Breaker_NW77_001.png as you can see the image exist... –  Clepto Jul 24 '12 at 12:27
    
The image MAY exist but the path for the image you are writing is wrong.Where is that image anyway?Why don't you move it to the Desktop or something like that and use /home/user/Desktop/image.png ? that would make your life a lot easier –  Nickolas Jul 24 '12 at 14:44
    
i download the image to /tmp for short-life use and then its deleted, thats why i save it to /tmp...Any other idea? except changing folder...can i use something else to display an image? –  Clepto Jul 24 '12 at 15:04
    
I told you that the problem is the path....the name of the file may be wrong. –  Nickolas Jul 24 '12 at 15:21
    
ok...thanks! i will mark you answer as solved –  Clepto Jul 24 '12 at 15:59
add comment

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.