本文整理汇总了Python中notify2.init方法的典型用法代码示例。如果您正苦于以下问题:Python notify2.init方法的具体用法?Python notify2.init怎么用?Python notify2.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notify2
的用法示例。
在下文中一共展示了notify2.init方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def run(self):
self.loop = GLib.MainLoop()
if self.config.notifications:
try:
notify2.init("pantalaimon", mainloop=self.loop)
self.notifications = True
except dbus.DBusException:
logger.error(
"Notifications are enabled but no notification "
"server could be found, disabling notifications."
)
self.notifications = False
GLib.timeout_add(100, self.message_callback)
if not self.loop:
return
self.loop.run()
示例2: notify
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def notify():
icon_path = "/home/dushyant/Desktop/Github/Crypto-Notifier/logo.jpg"
cryptocurrencies = ["BTC",
"ETH",
"LTC",
"XMR",
"XRP",]
result = "\n"
for coin in cryptocurrencies:
rate = fetch_coin(coin, "USD")
result += "{} - {}\n".format(coin, "$"+str(rate))
# print result
notify2.init("Cryptocurrency rates notifier")
n = notify2.Notification("Crypto Notifier", icon=icon_path)
n.set_urgency(notify2.URGENCY_NORMAL)
n.set_timeout(1000)
n.update("Current Cryptocurrency Rates", result)
n.show()
示例3: show_GUI
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def show_GUI():
def show_notify():
try:
import notify2
notify2.init('Tickeys')
title = 'Tickeys'
body = '程序“xdotool”尚未安装, 无法隐藏窗口。'
iconfile = os.getcwd() + '/tickeys.png'
notify = notify2.Notification(title, body, iconfile)
notify.show()
except Exception:
return
try:
GUIID = read_GUI_window_id()
if not GUIID or GUIID == "0":
Thread(target=show_notify).start()
return
else:
# read window ids
command = "xdotool windowmap --sync %s && xdotool windowactivate --sync %s" % (GUIID, GUIID)
stat, output = commands.getstatusoutput(command)
return str(stat)
except Exception, e:
logger.error(str(e))
return '256'
示例4: update_assets
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def update_assets(self):
self.discoveries += 1
if self.discoveries < len([ex for ex in self.EXCHANGES if ex.active and ex.discovery]):
return # wait until all active exchanges with discovery finish discovery
self.discoveries = 0
self._load_assets()
if notify2.init(self.config.get('app').get('name')):
n = notify2.Notification(
self.config.get('app').get('name'),
"Finished discovering new assets",
self.icon)
n.set_urgency(1)
n.timeout = 2000
n.show()
self.main_item.set_icon_full(self.icon, "App icon")
# Handle system resume by refreshing all tickers
示例5: __notify
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __notify(self, price, direction, threshold):
exchange_name = self.parent.exchange.get_name()
asset_name = self.parent.exchange.asset_pair.get('base')
title = asset_name + ' price alert: ' + self.parent.symbol + str(price)
message = 'Price on ' + exchange_name + ' ' + direction + ' ' + self.parent.symbol + str(threshold)
if notify2.init(self.app_name):
if pygame.init():
pygame.mixer.music.load(self.parent.coin.config.get('project_root') + '/resources/ca-ching.wav')
pygame.mixer.music.play()
logo = GdkPixbuf.Pixbuf.new_from_file(
self.parent.coin.config.get('project_root') + '/resources/icon_32px.png')
n = notify2.Notification(title, message)
n.set_icon_from_pixbuf(logo)
n.set_urgency(2) # highest
n.show()
示例6: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __init__(self, parent, device_id, device_name):
super(BatteryNotifier, self).__init__()
self._logger = logging.getLogger('razer.device{0}.batterynotifier'.format(device_id))
self._notify2 = notify2 is not None
self.event = threading.Event()
if self._notify2:
try:
notify2.init('openrazer_daemon')
except Exception as err:
self._logger.warning("Failed to init notification daemon, err: {0}".format(err))
self._notify2 = False
self._shutdown = False
self._device_name = device_name
# Could save reference to parent but only need battery level function
self._get_battery_func = parent.getBattery
if self._notify2:
self._notification = notify2.Notification(summary="{0}")
self._notification.set_timeout(NOTIFY_TIMEOUT)
self._last_notify_time = datetime.datetime(1970, 1, 1)
示例7: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __init__(self):
notify2.init("pyrdp-player")
super(NotifyHandler, self).__init__()
示例8: _pluginInstallPlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def _pluginInstallPlugin(self,plugin):
notify2.init("duck-launcher")
n=notify2.Notification("The plugin '{}' is installing".format(plugin),
"",
"dialog-information")
n.show()
self.parent.close_it()
t = installPlugin(parent=self.parent)
t.plugin=plugin
t.start()
self.parent.close_it()
示例9: _pluginRemovePlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def _pluginRemovePlugin(self,plugin):
notify2.init("duck-launcher")
n=notify2.Notification("The plugin '{}' is uninstalling".format(plugin),
"",
"dialog-information")
n.show()
self.parent.close_it()
t = removePlugin(parent=self.parent)
t.plugin=plugin
t.start()
示例10: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __init__(self):
self.plugins=[]
notify2.init("duck launcher")
示例11: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __init__(self):
notify2.uninit()
notify2.init('sun')
self.pkg_count = len(fetch())
self.summary = f"{' ' * 10}Software Updates"
self.message = f"{' ' * 3}{self.pkg_count} Software updates are available\n"
self.icon = f'{icon_path}{__all__}.png'
self.n = notify2.Notification(self.summary, self.message, self.icon)
self.n.set_timeout(60000 * int(config()['STANDBY']))
示例12: show_notify
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def show_notify(notify_content=""):
try:
notify2.init('Tickeys')
title = 'Tickeys'
icon_file_path = os.getcwd() + '/tickeys.png'
notify = notify2.Notification(title, notify_content, icon_file_path)
notify.show()
except Exception, e:
logger.exception(e)
logger.error("show notify fail")
示例13: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def __init__(self) -> None:
print("Configuring Desktop Notifier...")
notify2.init("UoM-WAM-Spam")
self.notification = notify2.Notification
self.timeout = notify2.EXPIRES_NEVER
示例14: sound
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import init [as 别名]
def sound(error=False):
mixer.init()
mixer.music.load(notify.sound_warn if error else notify.sound_info)
mixer.music.play()