当前位置: 首页>>代码示例>>Python>>正文


Python Notify.init方法代码示例

本文整理汇总了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 
开发者ID:Jessewb786,项目名称:Silaty,代码行数:22,代码来源:prayertime.py

示例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) 
开发者ID:atareao,项目名称:daily-wallpaper,代码行数:21,代码来源:dwdownloader.py

示例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 
开发者ID:jpmens,项目名称:mqttwarn,代码行数:25,代码来源:linuxnotify.py

示例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 
开发者ID:rolandasb,项目名称:twitch-indicator,代码行数:26,代码来源:run.py

示例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() 
开发者ID:maateen,项目名称:battery-monitor,代码行数:20,代码来源:Notification.py

示例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() 
开发者ID:autokey,项目名称:autokey,代码行数:19,代码来源:notifier.py

示例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") 
开发者ID:eavatar,项目名称:eavatar-me,代码行数:20,代码来源:shell.py

示例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 = [] 
开发者ID:rubyAce71697,项目名称:cricket-score-applet,代码行数:27,代码来源:cric_indicator.py

示例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 
开发者ID:Oros42,项目名称:ARP_poisoning_detector,代码行数:19,代码来源:arp_poisoning_detector.py

示例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 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:18,代码来源:utils.py

示例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() 
开发者ID:DoTheEvo,项目名称:ANGRYsearch,代码行数:28,代码来源:angrysearch_update_database.py

示例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) 
开发者ID:Dragon2fly,项目名称:vpngate-with-proxy,代码行数:32,代码来源:vpn_indicator.py

示例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 
开发者ID:epoptes,项目名称:epoptes,代码行数:16,代码来源:notifications.py

示例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) 
开发者ID:atareao,项目名称:lplayer,代码行数:6,代码来源:lplayer.py

示例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() 
开发者ID:getting-things-gnome,项目名称:gtg,代码行数:13,代码来源:notification.py


注:本文中的gi.repository.Notify.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。