Friday, May 3, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1213  / 3 Years ago, fri, october 1, 2021, 11:09:06

I am using this code to try to add submenus in appindicator



#!/usr/bin/env python
import gobject
import gtk
import appindicator

def clean_quit(w):
print "in quit"
gtk.main_quit()

if __name__ == "__main__":
ind = appindicator.Indicator ("example-simple-client",
"indicator-messages",
appindicator.CATEGORY_APPLICATION_STATUS)
ind.set_status (appindicator.STATUS_ACTIVE)
ind.set_attention_icon ("indicator-messages-new")

# create a menu
menu = gtk.Menu()
listMenu=gtk.Menu()
listItems=gtk.MenuItem("Show List")
listItems.set_submenu(listMenu)
inews = gtk.MenuItem("Import")
listMenu.append(inews)
menu.append(listItems)
listItems.show()
# create some
menu_items=gtk.MenuItem("Quit")
menu.append(menu_items)
menu_items.connect("activate", clean_quit)
menu_items.show()
ind.set_menu(menu)

gtk.main()


It's not working - what is wrong in this code?


More From » application-development

 Answers
6

You also forgot to call inews.show().


[#37384] Sunday, October 3, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ippalogu

Total Points: 215
Total Questions: 127
Total Answers: 146

Location: Denmark
Member since Tue, Jul 19, 2022
2 Years ago
ippalogu questions
Tue, Jan 4, 22, 21:49, 2 Years ago
Tue, Sep 21, 21, 09:12, 3 Years ago
Wed, May 19, 21, 02:24, 3 Years ago
Mon, Dec 27, 21, 01:44, 2 Years ago
;