Преглед на файлове

example-tray-icon

master
Dejvino преди 3 години
родител
ревизия
1ed6b9f849
променени са 2 файла, в които са добавени 53 реда и са изтрити 0 реда
  1. +14
    -0
      example-tray-icon/README.md
  2. +39
    -0
      example-tray-icon/tray.py

+ 14
- 0
example-tray-icon/README.md Целия файл

@@ -0,0 +1,14 @@
# Tray Icon Notification
Shows a custom notification icon with a menu in the tray area of your desktop.

## Dependencies
- Python
- GTK3
- AppIndicator3 (libappindicator-gtk3)

## Resources
- Source Tutorial: [Create a Custom System Tray Indicator For Your Tasks on Linux](https://fosspost.org/custom-system-tray-icon-indicator-linux/)
- Background on app indicators: [ApplicationIndicators](https://wiki.ubuntu.com/DesktopExperienceTeam/ApplicationIndicators)
- [Python GTK3 Tutorial](https://python-gtk-3-tutorial.readthedocs.io/en/latest/)
- [PyGObject](https://pygobject.readthedocs.io/en/latest/index.html)


+ 39
- 0
example-tray-icon/tray.py Целия файл

@@ -0,0 +1,39 @@
#!/usr/bin/python
import os
import gi

gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')

from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator

def main():
indicator = appindicator.Indicator.new("customtray", "semi-starred-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(menu())
gtk.main()

def menu():
menu = gtk.Menu()
command_one = gtk.MenuItem(label='My Notes')
command_one.connect('activate', note)
menu.append(command_one)

exittray = gtk.MenuItem(label='Exit Tray')
exittray.connect('activate', quit)
menu.append(exittray)
menu.show_all()
return menu
def note(_):
os.system("gvim $HOME/notes.txt")

def quit(_):
gtk.main_quit()

if __name__ == "__main__":
main()


Зареждане…
Отказ
Запис