本文整理汇总了Python中notify2.Notification方法的典型用法代码示例。如果您正苦于以下问题:Python notify2.Notification方法的具体用法?Python notify2.Notification怎么用?Python notify2.Notification使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notify2
的用法示例。
在下文中一共展示了notify2.Notification方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unverified_notification
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def unverified_notification(self, message):
notificaton = notify2.Notification(
"Unverified devices.",
message=(
f"There are unverified devices in the room "
f"{message.room_display_name}."
),
)
notificaton.set_category("im")
def send_cb(notification, action_key, user_data):
message = user_data
self.control_if.SendAnyways(message.pan_user, message.room_id)
def cancel_cb(notification, action_key, user_data):
message = user_data
self.control_if.CancelSending(message.pan_user, message.room_id)
if "actions" in notify2.get_server_caps():
notificaton.add_action("send", "Send anyways", send_cb, message)
notificaton.add_action("cancel", "Cancel sending", cancel_cb, message)
notificaton.show()
示例2: notify
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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: installPlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def installPlugin(self,plugin):
destination=os.path.join("/usr/share/duck-launcher/plugins/",plugin)
path_to_download= "https://github.com/the-duck/launcher-plugins/trunk/{}".format(str(plugin))
try:
subprocess.call(["gksudo", "duck-plugins install --repo {}".format(plugin)])
success=True
except Exception as e:
success=False
if not os.path.isdir(destination):
success=False
if success==True:
n = notify2.Notification("Plugin installation successful",
"The plugin <b>{}</b> has been successfully installed".format(plugin),
"dialog-information" # Icon nam
)
n.show()
elif success==False:
n = notify2.Notification("Could not install plugin '{}'".format(plugin),
"Please check your internet connection",
"dialog-error" # Icon name
)
n.show()
示例4: removePlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def removePlugin(self, plugin):
destination=os.path.join("/usr/share/duck-launcher/plugins/",plugin)
try:
subprocess.call(["gksudo", "duck-plugins remove {}".format(plugin)])
success=True
except Exception:
success=False
if os.path.isdir(destination):
success==False
if success==True:
n = notify2.Notification("The plugin'{}' has been successfully removed".format(plugin),
"",
"dialog-information" # Icon nam
)
n.show()
elif success==False:
n = notify2.Notification("Could not remove plugin '{}'".format(plugin),
"Please report this bug",
"dialog-error" # Icon name
)
n.show()
示例5: show_GUI
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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'
示例6: update_assets
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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
示例7: __notify
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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()
示例8: __init__
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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)
示例9: show
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def show(title, message, icon=''):
try:
notice = notify2.Notification(title, message, icon)
notice.set_timeout(notify2.EXPIRES_DEFAULT)
notice.show()
except:
logger.info(
'notify2 failed to display: {title} - {message}'.format(
title=title,
message=message))
示例10: sas_invite_notification
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def sas_invite_notification(self, message):
notificaton = notify2.Notification(
"Key verification invite",
message=(
f"{message.user_id} via {message.device_id} has started "
f"a key verification process."
),
)
notificaton.set_category("im")
def accept_cb(notification, action_key, user_data):
message = user_data
self.device_if.AcceptKeyVerification(
message.pan_user, message.user_id, message.device_id
)
def cancel_cb(notification, action_key, user_data):
message = user_data
self.device_if.CancelKeyVerification(
message.pan_user, message.user_id, message.device_id
)
if "actions" in notify2.get_server_caps():
notificaton.add_action("accept", "Accept", accept_cb, message)
notificaton.add_action("cancel", "Cancel", cancel_cb, message)
notificaton.show()
示例11: sas_show_notification
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def sas_show_notification(self, message):
emojis = [x[0] for x in message.emoji]
emoji_str = " ".join(emojis)
notificaton = notify2.Notification(
"Short authentication string",
message=(
f"Short authentication string for the key verification of"
f" {message.user_id} via {message.device_id}:\n"
f"{emoji_str}"
),
)
notificaton.set_category("im")
def confirm_cb(notification, action_key, user_data):
message = user_data
self.device_if.ConfirmKeyVerification(
message.pan_user, message.user_id, message.device_id
)
def cancel_cb(notification, action_key, user_data):
message = user_data
self.device_if.CancelKeyVerification(
message.pan_user, message.user_id, message.device_id
)
if "actions" in notify2.get_server_caps():
notificaton.add_action("confirm", "Confirm", confirm_cb, message)
notificaton.add_action("cancel", "Cancel", cancel_cb, message)
notificaton.show()
示例12: sas_done_notification
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def sas_done_notification(self, message):
notificaton = notify2.Notification(
"Device successfully verified.",
message=(
f"Device {message.device_id} of user {message.user_id} "
f"successfully verified."
),
)
notificaton.set_category("im")
notificaton.show()
示例13: emit
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [as 别名]
def emit(self, record):
"""
Send a notification.
:param record: the LogRecord object
"""
notification = notify2.Notification(record.getMessage())
notification.show()
示例14: _pluginInstallPlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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()
示例15: _pluginRemovePlugin
# 需要导入模块: import notify2 [as 别名]
# 或者: from notify2 import Notification [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()