def create_menuitem(string, stock_id=None): from gtk import MenuItem, Image, HBox, Label hbox = HBox(spacing=7) hbox.set_property("border-width", 2) if stock_id: image = Image() image.set_property("stock", stock_id) hbox.pack_start(image, False, False, 0) label = Label(string) label.set_property("use-underline", True) hbox.pack_start(label, False, False, 0) menuitem = MenuItem() menuitem.add(hbox) return menuitem