python - How to display an image next to a menu item? -
i trying image appear next menu item isn't working.
in order make simple possible, have created simple example below highlights problem:
import pygtk pygtk.require('2.0') import gtk class menuexample: def __init__(self): window = gtk.window() window.set_size_request(200, 100) window.connect("delete_event", lambda w,e: gtk.main_quit()) menu = gtk.menu() menu_item = gtk.imagemenuitem("refresh") img = gtk.image_new_from_stock(gtk.stock_refresh, gtk.icon_size_menu) img.show() menu_item.set_image(img) menu.append(menu_item) menu_item.show() root_menu = gtk.menuitem("file") root_menu.show() root_menu.set_submenu(menu) vbox = gtk.vbox(false, 0) window.add(vbox) vbox.show() menu_bar = gtk.menubar() vbox.pack_start(menu_bar, false, false, 2) menu_bar.show() menu_bar.append(root_menu) window.show() def main(): gtk.main() return 0 if __name__ == "__main__": menuexample() main()
when run application, shows menu item, not show image next it.
os: ubuntu 10.04 64-bit
python version: 2.6.5
hmmm... turns out answer desktop theme had disabled icons menus. (who knows why.)
after enabling option, icons show up.
Comments
Post a Comment