Created
February 12, 2015 20:59
-
-
Save candidtim/4705c55d41ae982ee60e to your computer and use it in GitHub Desktop.
Minimal Ubuntu AppIndicator in Python, with "Quit" menu item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
from gi.repository import Gtk as gtk | |
from gi.repository import AppIndicator3 as appindicator | |
APPINDICATOR_ID = 'myappindicator' | |
def main(): | |
indicator = appindicator.Indicator.new(APPINDICATOR_ID, 'whatever', appindicator.IndicatorCategory.SYSTEM_SERVICES) | |
indicator.set_status(appindicator.IndicatorStatus.ACTIVE) | |
indicator.set_menu(build_menu()) | |
gtk.main() | |
def build_menu(): | |
menu = gtk.Menu() | |
item_quit = gtk.MenuItem('Quit') | |
item_quit.connect('activate', quit) | |
menu.append(item_quit) | |
menu.show_all() | |
return menu | |
def quit(source): | |
gtk.main_quit() | |
if __name__ == "__main__": | |
signal.signal(signal.SIGINT, signal.SIG_DFL) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment