本文整理匯總了Python中pynotify.Notification方法的典型用法代碼示例。如果您正苦於以下問題:Python pynotify.Notification方法的具體用法?Python pynotify.Notification怎麽用?Python pynotify.Notification使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pynotify
的用法示例。
在下文中一共展示了pynotify.Notification方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: a_notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def a_notify(notification, title, description, priority=pynotify.URGENCY_LOW):
'''Returns whether notifications should be sticky.'''
is_away = STATE['is_away']
icon = STATE['icon']
time_out = 5000
if weechat.config_get_plugin('sticky') == 'on':
time_out = 0
if weechat.config_get_plugin('sticky_away') == 'on' and is_away:
time_out = 0
try:
pynotify.init("wee-notifier")
wn = pynotify.Notification(title, description, icon)
wn.set_urgency(priority)
wn.set_timeout(time_out)
wn.show()
except Exception as error:
weechat.prnt('', 'anotify: {0}'.format(error))
# -----------------------------------------------------------------------------
# Main
# -----------------------------------------------------------------------------
示例2: saveCode
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def saveCode(self):
fn = QtGui.QFileDialog.getSaveFileName(
self,
self.trUtf8('Save QRCode'),
filter=self.trUtf8('PNG Images (*.png);; All Files (*.*)')
)
if fn:
if not fn.toLower().endsWith(u".png"):
fn += u".png"
self.qrcode.pixmap().save(fn)
if NOTIFY:
n = pynotify.Notification(
unicode(self.trUtf8("Save QR Code")),
unicode(self.trUtf8("QR Code succesfully saved to %s")) % fn,
"qtqr"
)
n.show()
else:
QtGui.QMessageBox.information(
self,
unicode(self.trUtf8('Save QRCode')),
unicode(self.trUtf8('QRCode succesfully saved to <b>%s</b>.')) % fn
)
示例3: check_ding
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def check_ding(account, sender, message, conv, flags):
sender = sender.encode('utf-8')
message = message.encode('utf-8')
obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
title = purple.PurpleConversationGetTitle(conv).encode('utf-8')
if not title:
title = conv
if len(dingregex.findall(message)) > 0:
pass
#pynotify.init("Basics")
#notify = pynotify.Notification("DING DING DING","{} called for DING DING DING in {}".format(sender,title),"emblem-danger")
#notify.set_timeout(pynotify.EXPIRES_NEVER)
#notify.show()
if DEBUG:
print "sender: {} message: {}, account: {}, conversation: {}, flags: {}, title: {}".format(sender,message,account,conv,flags,title)
f=open("_","w")
f.write(message)
f.close()
os.system("echo '%s' | python _sendFAX.py localhost 10111 Star +bw" % sender)
os.system("cat _ | python _sendFAX.py localhost 10111 Star -")
示例4: notify_general
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def notify_general(self, msg="msg", title="Title", buttons={}, timeout=3600):
if not pynotify:
return False
n = pynotify.Notification('Test', msg)
for k in buttons:
data = buttons[k]["data"]
label = buttons[k]["label"]
callback = buttons[k]["callback"]
n.add_action(data, label, callback)
n.set_timeout(timeout)
n.show()
self.notify_list.append(n)
return True
示例5: notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def notify(title, body, icon):
n = pynotify.Notification(title, body, icon)
n.set_hint_string("x-canonical-append", "true")
n.show()
示例6: cached_notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def cached_notify(title, body, icon):
"""A function to replace pynotify.notify if the 'x-canonical-append'
capability is not provided.
"""
n = cache.get_notification(title)
if n:
n.close()
n.update(title, n.props.body+'\n'+body, icon)
else:
n = pynotify.Notification(title, body, icon)
cache.add_notification(n, title)
n.show()
示例7: showMessage
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def showMessage(self, body):
if self.usePynotify:
n = pynotify.Notification("pyload", body, join(pypath, "icons", "logo.png"))
try:
n.set_hint_string("x-canonical-append", "")
except:
pass
n.show()
else:
self.tray.showMessage("pyload", body)
示例8: sendMessage
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def sendMessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
示例9: notify_user
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def notify_user(self, message='Hello'):
if pynotify:
notification = pynotify.Notification(
self.config.get('app_name', 'gui-o-matic'),
message, "dialog-warning")
notification.set_urgency(pynotify.URGENCY_NORMAL)
notification.show()
else:
print('FIXME: Notify: %s' % message)
示例10: sendmessage
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def sendmessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
示例11: notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def notify(self, title, message, icon):
title = "%s - %s" % (self.appname, title)
try:
notification = pynotify.Notification(title, message, icon)
except TypeError:
notification = pynotify.Notification(title, message)
notification.show()
示例12: show_notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def show_notify(self, message=None, timeout=None):
if pynotify and message:
notification = pynotify.Notification('GoAgent Notify', message)
notification.set_hint('x', 200)
notification.set_hint('y', 400)
if timeout:
notification.set_timeout(timeout)
notification.show()
示例13: show_notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def show_notify(self, message=None, timeout=None):
if pynotify and message:
notification = pynotify.Notification('XX-Mini Notify', message)
notification.set_hint('x', 200)
notification.set_hint('y', 400)
if timeout:
notification.set_timeout(timeout)
notification.show()
示例14: make_notification
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def make_notification(title: str, message: str="", name: str="",
icon: str="", timeout: int=3_000) -> bool:
"""Notification message with information,based on D-Bus,with Fallbacks."""
if dbus: # Theorically the standard universal way.
log.debug(f"Sending Notification message using the API of {dbus}.")
return bool(dbus.Interface(dbus.SessionBus().get_object(
"org.freedesktop.Notifications", "/org/freedesktop/Notifications"),
"org.freedesktop.Notifications").Notify(
name, 0, icon, title, message, [], [], timeout))
elif pynotify: # The non-standard non-universal way.
log.debug(f"Sending Notification message using the API of {pynotify}.")
pynotify.init(name.lower() if name else title.lower())
return pynotify.Notification(title, message).show()
elif which("notify-send"): # The non-standard non-universal sucky ways.
log.debug("Sending Notification message via notify-send command.")
comand = (which("notify-send"), f"--app-name={name}",
f"--expire-time={timeout}", title, message)
return not bool(
run(comand, timeout=timeout // 1_000 + 1, shell=True).returncode)
elif which("kdialog"):
log.debug("Sending Notification message via KDialog command.")
comand = (which("kdialog"), f"--name={name}", f"--title={title}",
f"--icon={icon}", f"--caption={name}", "--passivepopup",
title + message, str(timeout // 1_000))
return not bool(
run(comand, timeout=timeout // 1_000 + 1, shell=True).returncode)
elif which("zenity"):
log.debug("Sending Notification message via Zenity command.")
comand = (which("zenity"), f"--name={name}", f"--title={title}",
"--notification", f"--timeout={timeout // 1_000}",
f"--text={title + message}")
return not bool(
run(comand, timeout=timeout // 1_000 + 1, shell=True).returncode)
else: # Windows and Mac dont have API for that, complain to them.
log.warning("Sending Notifications not supported by this OS.")
return False
示例15: qrencode
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import Notification [as 別名]
def qrencode(self):
#Functions to get the correct data
data_fields = {
"text": unicode(self.textEdit.toPlainText()),
"url": unicode(self.urlEdit.text()),
"bookmark": ( unicode(self.bookmarkTitleEdit.text()), unicode(self.bookmarkUrlEdit.text()) ),
"email": unicode(self.emailEdit.text()),
"emailmessage": ( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ),
"telephone": unicode(self.telephoneEdit.text()),
"phonebook": (('N',unicode(self.phonebookNameEdit.text())),
('TEL', unicode(self.phonebookTelEdit.text())),
('EMAIL',unicode(self.phonebookEMailEdit.text())),
('NOTE', unicode(self.phonebookNoteEdit.text())),
('BDAY', unicode(self.phonebookBirthdayEdit.date().toString("yyyyMMdd"))), #YYYYMMDD
('ADR', unicode(self.phonebookAddressEdit.text())), #The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order.
('URL', unicode(self.phonebookUrlEdit.text())),
# ('NICKNAME', ''),
),
"sms": ( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ),
"mms": ( unicode(self.mmsNumberEdit.text()), unicode(self.mmsBodyEdit.toPlainText()) ),
"geo": ( unicode(self.geoLatEdit.text()), unicode(self.geoLongEdit.text()) ),
}
data_type = unicode(self.templates[unicode(self.selector.currentText())])
data = data_fields[data_type]
level = (u'L',u'M',u'Q',u'H')
if data:
if data_type == 'emailmessage' and data[1] == '' and data[2] == '':
data_type = 'email'
data = data_fields[data_type]
qr = QR(pixel_size = unicode(self.pixelSize.value()),
data = data,
level = unicode(level[self.ecLevel.currentIndex()]),
margin_size = unicode(self.marginSize.value()),
data_type = data_type,
)
if qr.encode() == 0:
self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
self.saveButton.setEnabled(True)
else:
if NOTIFY:
n = pynotify.Notification(
"QtQR",
unicode(self.trUtf8("ERROR: Something went wrong while trying to generate the QR Code.")),
"qtqr"
)
n.show()
else:
print "Something went worng while trying to generate the QR Code"
else:
self.saveButton.setEnabled(False)