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 developing a PyGtk application that I would like to display the image for a USB stick from the user's theme. However, I cannot seem to pin down the name of the icon, and Google is no help. Consider the following code:

 import pygtk
 pygtk.require('2.0')
 require gtk

 icon_theme = gtk.icon_theme_get_default()
 icon_theme.has_icon('firefox') #True
 icon_theme.has_icon('google-chrome') #True
 icon_theme.has_icon('usb') #False. I have also tried "drive", and "usb-drive".
  • Can you suggest a query?
  • Is the USB stick icon discoverable this way? Should I look elsewhere?
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Using the function list_icons():

icons=icon_theme.list_icons()
for icon in icons:
    if 'usb' in icon:
       print icon

and the output:

drive-removable-media-usb
usbpendrive_unmount
gnome-dev-removable-usb
usb-creator
drive-harddisk-usb
gnome-dev-harddisk-usb
gnome-dev-unknown-usb
usb-creator-gtk
drive-harddisk-usb-symbolic

Now take your pic

share|improve this answer
    
I think that should be "icon" in the for loop, and not "icons" :D –  dejay Apr 10 '13 at 1:03
    
yep... sorry bout that –  Ian B. Apr 10 '13 at 1:21
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.