本文整理匯總了Python中pynotify.init方法的典型用法代碼示例。如果您正苦於以下問題:Python pynotify.init方法的具體用法?Python pynotify.init怎麽用?Python pynotify.init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pynotify
的用法示例。
在下文中一共展示了pynotify.init方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: a_notify
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [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: startMain
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def startMain(self):
"""
start all refresh threads and show main window
"""
if not self.connector.connectProxy():
self.init()
return
self.connect(self.connector, SIGNAL("connectionLost"), self.slotConnectionLost)
self.restoreMainWindow()
self.mainWindow.show()
self.initQueue()
self.initPackageCollector()
self.mainloop.start()
self.clipboard = self.app.clipboard()
self.connect(self.clipboard, SIGNAL('dataChanged()'), self.slotClipboardChange)
self.mainWindow.actions["clipboard"].setChecked(self.checkClipboard)
self.mainWindow.tabs["settings"]["w"].setConnector(self.connector)
self.mainWindow.tabs["settings"]["w"].loadConfig()
self.tray.showAction.setDisabled(False)
示例3: check_ding
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [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: __init__
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def __init__(self):
"""
main setup
"""
QObject.__init__(self)
self.app = QApplication(sys.argv)
self.path = pypath
self.homedir = abspath("")
self.configdir = ""
self.init(True)
示例5: slotShowConnector
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def slotShowConnector(self):
"""
emitted from main window (menu)
hide the main window and show connection manager
(to switch to other core)
"""
self.quitInternal()
self.stopMain()
self.init()
#def quit(self): #not used anymore?
# """
# quit gui
# """
# self.app.quit()
示例6: sendMessage
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def sendMessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
示例7: __init__
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def __init__(self, config):
BaseGUI.__init__(self, config)
if pynotify:
pynotify.init(config.get('app_name', 'gui-o-matic'))
gobject.threads_init()
self.splash = None
示例8: sendmessage
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def sendmessage(title, message):
pynotify.init("Test")
notice = pynotify.Notification(title, message)
notice.show()
return
示例9: __init__
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def __init__(self, appname):
self.appname = appname
if not pynotify.init(appname):
log("PyNotify failed to initialize with appname: %s" % appname, LEVEL_DEBUG)
示例10: make_notification
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [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
示例11: init
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def init(self, first=False):
"""
set main things up
"""
self.parser = XMLParser(join(self.configdir, "gui.xml"), join(self.path, "module", "config", "gui_default.xml"))
lang = self.parser.xml.elementsByTagName("language").item(0).toElement().text()
if not lang:
parser = XMLParser(join(self.path, "module", "config", "gui_default.xml"))
lang = parser.xml.elementsByTagName("language").item(0).toElement().text()
gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
translation = gettext.translation("pyLoadGui", join(pypath, "locale"), languages=[str(lang), "en"], fallback=True)
try:
translation.install(unicode=(True if sys.stdout.encoding.lower().startswith("utf") else False))
except:
translation.install(unicode=False)
self.connector = Connector()
self.mainWindow = MainWindow(self.connector)
self.connWindow = ConnectionManager()
self.mainloop = self.Loop(self)
self.connectSignals()
self.checkClipboard = False
default = self.refreshConnections()
self.connData = None
self.captchaProcessing = False
self.serverStatus = {"freespace":0}
self.core = None # pyLoadCore if started
self.connectionLost = False
if True: # when used if first, minimizing not working correctly..
self.tray = TrayIcon()
self.tray.show()
self.notification = Notification(self.tray)
self.connect(self, SIGNAL("showMessage"), self.notification.showMessage)
self.connect(self.tray.exitAction, SIGNAL("triggered()"), self.slotQuit)
self.connect(self.tray.showAction, SIGNAL("toggled(bool)"), self.mainWindow.setVisible)
self.connect(self.mainWindow, SIGNAL("hidden"), self.tray.mainWindowHidden)
if not first:
self.connWindow.show()
else:
self.connWindow.edit.setData(default)
data = self.connWindow.edit.getData()
self.slotConnect(data)
示例12: initPackageCollector
# 需要導入模塊: import pynotify [as 別名]
# 或者: from pynotify import init [as 別名]
def initPackageCollector(self):
"""
init the package collector view
* columns
* selection
* refresh thread
* drag'n'drop
"""
view = self.mainWindow.tabs["collector"]["package_view"]
view.setSelectionBehavior(QAbstractItemView.SelectRows)
view.setSelectionMode(QAbstractItemView.ExtendedSelection)
def dropEvent(klass, event):
event.setDropAction(Qt.CopyAction)
event.accept()
view = event.source()
if view == klass:
items = view.selectedItems()
for item in items:
if not hasattr(item.parent(), "getPackData"):
continue
target = view.itemAt(event.pos())
if not hasattr(target, "getPackData"):
target = target.parent()
klass.emit(SIGNAL("droppedToPack"), target.getPackData()["id"], item.getFileData()["id"])
event.ignore()
return
items = view.selectedItems()
for item in items:
row = view.indexOfTopLevelItem(item)
view.takeTopLevelItem(row)
def dragEvent(klass, event):
#view = event.source()
#dragOkay = False
#items = view.selectedItems()
#for item in items:
# if hasattr(item, "_data"):
# if item._data["id"] == "fixed" or item.parent()._data["id"] == "fixed":
# dragOkay = True
# else:
# dragOkay = True
#if dragOkay:
event.accept()
#else:
# event.ignore()
view.dropEvent = dropEvent
view.dragEnterEvent = dragEvent
view.setDragEnabled(True)
view.setDragDropMode(QAbstractItemView.DragDrop)
view.setDropIndicatorShown(True)
view.setDragDropOverwriteMode(True)
view.connect(view, SIGNAL("droppedToPack"), self.slotAddFileToPackage)
#self.packageCollector = PackageCollector(view, self.connector)
self.packageCollector = view.model()