我正在开发一个 PyGtk 应用程序,我想显示来自用户主题的 USB 记忆棒图像。但是,我似乎无法确定图标的名称,Google 也帮不上忙。请考虑以下代码:
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".
- 您能建议一个查询吗?
- 这样可以找到 USB 存储棒图标吗?我应该去别处找吗?
答案1
使用函数list_icons():
icons=icon_theme.list_icons()
for icon in icons:
if 'usb' in icon:
print icon
输出:
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
现在拍照