File: icon.py

package info (click to toggle)
python-notify2 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: python: 451; makefile: 145; sh: 7
file content (39 lines) | stat: -rwxr-xr-x 1,067 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
from __future__ import print_function

import notify2
from gi.repository import Gtk
import sys
import os

if __name__ == '__main__':
    if not notify2.init("Images Test"):
        sys.exit(1)

    # Stock icon
    n = notify2.Notification("Icon Test", "Testing stock icon",
                              "notification-message-email")

    if not n.show():
        print("Failed to send notification")
        sys.exit(1)

    # Image URI
    uri = "file://" + os.path.abspath(os.path.curdir) + "/applet-critical.png"
    print("Sending", uri)

    n = notify2.Notification("Alert!", "Testing URI icons", uri)
    if not n.show():
        print("Failed to send notification")
        sys.exit(1)

    # Raw image
    n = notify2.Notification("Raw image test",
                              "Testing sending raw pixbufs")
    helper = Gtk.Button()
    icon = helper.render_icon(Gtk.STOCK_DIALOG_QUESTION, Gtk.IconSize.DIALOG)
    n.set_icon_from_pixbuf(icon)

    if not n.show():
        print("Failed to send notification")
        sys.exit(1)