本文整理汇总了Python中gi.repository.Notify.init方法的典型用法代码示例。如果您正苦于以下问题:Python Notify.init方法的具体用法?Python Notify.init怎么用?Python Notify.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Notify
的用法示例。
在下文中一共展示了Notify.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self):
GLib.threads_init()
Gst.init(None)
self.options = Options()
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
self.date = date(year, month, day)
self._shrouk = None
self._fajr = None
self._zuhr = None
self._asr = None
self._maghrib = None
self._isha = None
self._nextprayer = ""
self._tnprayer = 0
self.dec = 0
示例2: notify_photo_caption
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def notify_photo_caption(title, caption=None, credit=None):
if caption:
caption = max_length(caption, 60) if len(caption) > 60 else caption
for m in ['<p>', '</p>', '<br>', '<br />']:
caption = caption.replace(m, '')
if credit:
caption = '\n{}\n\n<i>{}</i>: {}'.format(caption,
_('Photo credit'),
credit)
else:
caption = ''
try:
Notify.init(title)
info = Notify.Notification.new(title, caption, 'dialog-information')
info.set_timeout(Notify.EXPIRES_DEFAULT)
info.set_urgency(Notify.Urgency.LOW)
info.show()
except Exception as e:
print(e)
示例3: plugin
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def plugin(srv, item):
"""Send a message to the user's desktop notification system."""
srv.logging.debug("*** MODULE=%s: service=%s, target=%s", __file__,
item.service, item.target)
title = item.addrs[0]
text = item.message
try:
srv.logging.debug("Sending notification to the user's desktop")
Notify.init('mqttwarn')
n = Notify.Notification.new(
title,
text,
'/usr/share/icons/gnome/32x32/places/network-server.png')
n.show()
srv.logging.debug("Successfully sent notification")
except Exception as e:
srv.logging.warning("Cannot invoke notification to linux: %s" % e)
return False
return True
示例4: push_notifications
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def push_notifications(self, streams):
"""Pushes notifications of every stream, passed as a list of dictionaries."""
try:
for stream in streams:
self.image = gtk.Image()
# Show default if channel owner has not set his avatar
if (stream["image"] == None):
self.response = urllib.urlopen("http://static-cdn.jtvnw.net/jtv_user_pictures/xarth/404_user_150x150.png")
else:
self.response = urllib.urlopen(stream["image"])
self.loader = GdkPixbuf.PixbufLoader.new()
self.loader.write(self.response.read())
self.loader.close()
Notify.init("image")
self.n = Notify.Notification.new("%s just went LIVE!" % stream["name"],
stream["status"],
"",
)
self.n.set_icon_from_pixbuf(self.loader.get_pixbuf())
self.n.show()
except IOError:
return
示例5: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self, type: str) -> None:
# initiating notification
Notify.init("Battery Monitor")
message = MESSAGES[type]
head = message[0]
body = message[1]
icon = ICONS[type]
self.last_percentage = 0
self.last_notification = ''
self.notifier = Notify.Notification.new(head, body, icon)
self.notifier.set_urgency(Notify.Urgency.CRITICAL)
try:
self.notifier.show()
except GLib.GError as e:
# fixing GLib.GError: g-dbus-error-quark blindly
pass
self.config = configparser.ConfigParser()
self.load_config()
示例6: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self, autokeyApp):
Notify.init("AutoKey")
# Used to rate-limit error notifications to 1 per second. Without this, two notifications per second cause the
# following exception, which in turn completely locks up the GUI:
# gi.repository.GLib.GError: g-io-error-quark:
# GDBus.Error:org.freedesktop.Notifications.Error.ExcessNotificationGeneration:
# Created too many similar notifications in quick succession (36)
self.last_notification_timestamp = datetime.datetime.now()
self.app = autokeyApp
self.configManager = autokeyApp.service.configManager
self.indicator = AppIndicator3.Indicator.new("AutoKey", cm.ConfigManager.SETTINGS[cm.NOTIFICATION_ICON],
AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_attention_icon(common.ICON_FILE_NOTIFICATION_ERROR)
self.update_visible_status()
self.rebuild_menu()
示例7: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self, shell):
self.shell = shell
self.ind = appindicator.Indicator.new(
"EAvatar-indicator",
resource_path(os.path.join(base.AVARES_PATH, "icon.png")),
appindicator.IndicatorCategory.APPLICATION_STATUS)
self.ind.set_icon_theme_path(resource_path(base.AVARES_PATH))
self.ind.set_status(appindicator.IndicatorStatus.ACTIVE)
self.ind.set_attention_icon("icon.png")
self.notices_menu = None
self.status_menu = None
self.old_status_item = None
self.menu_setup()
self.ind.set_menu(self.menu)
self.notification = None
Notify.init("EAvatar")
示例8: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self):
Notify.init("cricket score indicator")
self.notification = Notify.Notification.new("")
self.notification.set_app_name("Cricket Score")
"""
Initialize appindicator and other menus
"""
self.indicator = appindicator.Indicator.new("cricket-indicator",
ICON_PREFIX + DEFAULT_ICON+ ICON_SUFFIX ,
appindicator.IndicatorCategory.APPLICATION_STATUS)
# if DEBUG:
# self.indicator.set_icon_theme_path(DARK_ICONS)
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
self.indicator.set_label("Loading", "")
self.indicator.connect("scroll-event", self.scroll_event_cb)
self.menu_setup()
# the 'id' of match selected for display as indicator label
self.label_match_id = None
self.open_scorecard = set()
self.intl_menu = []
self.dom_menu = []
示例9: check_attack
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def check_attack(x):
if ARP in x and x[ARP].op == 2:
hwsrc= x.sprintf("%ARP.hwsrc%")
psrc= x.sprintf("%ARP.psrc%")
hwdst= x.sprintf("%ARP.hwdst%")
pdst= x.sprintf("%ARP.pdst%")
if psrc in arp:
if arp[psrc]!=hwsrc:
if bash_notif:
commands.getoutput("su - {} -c 'notify-send \"ARP poisoning risk!\" \"{} want {}\nBut {} is {}\n\nTarget {} ({})\" --icon=dialog-error'".format(user,hwsrc, psrc, psrc, arp[psrc], hwdst, pdst))
else:
if Notify.init ("Hello world"):
alert=Notify.Notification.new("ARP poisoning risk!","{} want {}\nBut {} is {}\n\nTarget {} ({})".format(hwsrc, psrc, psrc, arp[psrc], hwdst, pdst),"dialog-error")
alert.show ()
print("{} ; {} want {} ; But {} is {} ; Target {} ({})".format(strftime("%Y/%m/%d %H:%M:%S", gmtime()), hwsrc, psrc, psrc, arp[psrc], hwdst, pdst))
else:
arp[psrc]=hwsrc
示例10: notify
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def notify(message, title='AutomaThemely'):
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify, GLib
if not Notify.is_initted():
Notify.init('AutomaThemely')
n = Notify.Notification.new(title, message, get_resource('automathemely.svg'))
try: # I don't even know... https://bugzilla.redhat.com/show_bug.cgi?id=1582833
n.show()
except GLib.GError as e:
if str(e) != 'g-dbus-error-quark: Unexpected reply type (16)' \
and str(e) != 'g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message recipient ' \
'disconnected from message bus without replying (4)':
raise e
示例11: show_notification
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def show_notification(text):
global NOTIFY_AVAILABLE
global NOTIFICATIONS_ENABLED
if NOTIFY_AVAILABLE is False or NOTIFICATIONS_ENABLED is False:
print('angrysearch: Desktop notifications disabled or unavailable')
return
Notify.init('angrysearch')
n = Notify.Notification.new('ANGRYsearch:', text)
possible_image_locations = [
'angrysearch.svg',
'/usr/share/pixmaps/angrysearch.svg',
'/usr/share/angrysearch/angrysearch.svg',
'/opt/angrysearch/angrysearch.svg'
]
for x in possible_image_locations:
if os.path.exists(x):
icon = GdkPixbuf.Pixbuf.new_from_file(x)
n.set_image_from_pixbuf(icon)
break
else:
n.set_property('icon-name', 'drive-harddisk')
n.show()
示例12: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self, q_info, sender):
signal.signal(signal.SIGINT, self.handler)
signal.signal(signal.SIGTERM, self.handler)
# pipe for send/recv data to tcp server
self.q_info = q_info
self.send = sender
self.APPINDICATOR_ID = 'myappindicator'
self.icon1 = os.path.abspath('icon/connected.svg')
self.icon2 = os.path.abspath('icon/connectnot.svg')
self.icon345 = [os.path.abspath(icon) for icon in
['icon/connecting1.svg', 'icon/connecting2.svg', 'icon/connecting3.svg']]
self.hang = False
self.is_connecting = False
self.icon_th = 0
self.last_recv = ['']
self.indicator = appindicator.Indicator.new(self.APPINDICATOR_ID, self.icon2,
appindicator.IndicatorCategory.APPLICATION_STATUS)
self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
# Add menu to indicator
self.indicator.set_menu(self.build_menu())
self.notifier = notify.Notification.new('', '', None)
self.notifier.set_timeout(2)
notify.init(self.APPINDICATOR_ID)
示例13: __init__
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def __init__(self, summary, icon):
"""Initialize Notify and local variables."""
if not NotifyQueue.initialized:
NotifyQueue.initialized = True
if not Notify.init("Epoptes"):
raise ImportError(_('Could not initialize notifications!'))
self.summary = summary
self.icon = icon
self.items = []
# The heading of the last item enqueued
self.last_heading = ''
self.last_time = time.time()
self.notification = None
self.shown_error = False
示例14: main
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def main(args):
Notify.init('lplayer')
app = MainApplication()
app.run(args)
示例15: _notify_via_notify
# 需要导入模块: from gi.repository import Notify [as 别名]
# 或者: from gi.repository.Notify import init [as 别名]
def _notify_via_notify(title, message):
Notify.init(APP_NAME)
nt = Notify.Notification.new(title, message)
nt.set_timeout(TIMEOUT)
try:
nt.show()
except:
# Keep quiet here when notification service is not avialable currently
# sometime. For example, if user is using LXDE, no notifyd by default.
pass
Notify.uninit()