Skip to content

Instantly share code, notes, and snippets.

@ksvbka
Created May 4, 2018 06:48
Show Gist options
  • Select an option

  • Save ksvbka/b566d6fe56bd67a6fa989a3468657e7e to your computer and use it in GitHub Desktop.

Select an option

Save ksvbka/b566d6fe56bd67a6fa989a3468657e7e to your computer and use it in GitHub Desktop.
App Indicator demo. Create icon in systemtray. Work with both GTK and KDE
#!/usr/bin/python3
import signal
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk
from gi.repository import AppIndicator3 as AppIndicator
def main():
signal.signal(signal.SIGINT, signal.SIG_DFL)
item = Gtk.MenuItem('Quit')
item.connect('activate', Gtk.main_quit)
menu = Gtk.Menu()
menu.append(item)
menu.show_all()
APPINDICATOR_ID = 'DemoApp'
ICON = 'dialog-information' # Get default icon from /usr/share/icons/gnome/16x16/
indicator = AppIndicator.Indicator.new(
APPINDICATOR_ID, ICON, AppIndicator.IndicatorCategory.APPLICATION_STATUS)
indicator.set_status(AppIndicator.IndicatorStatus.ACTIVE)
indicator.set_menu(menu)
Gtk.main()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment