本文整理汇总了Python中notify2.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, appname, icon, urgency=None, timeout=None):
self._appname = appname
self._icon = icon
self._urgency = urgency if urgency else notify2.URGENCY_NORMAL
self._timeout = timeout if timeout else 1000
notify2.init(self._appname)
self._nobj = notify2.Notification(appname, icon=ICON)
示例2: display
def display(title, msg):
logging.debug("NOTIFY DISPLAY")
if sys.platform == "linux":
import notify2
import dbus
if not notify2.is_initted():
logging.debug("Initialising notify2")
notify2.init("cutecoin")
n = notify2.Notification(title,
msg)
# fixme: https://bugs.python.org/issue11587
# # Not working... Empty icon at the moment.
# icon = QPixmap(":/icons/cutecoin_logo/").toImage()
# if icon.isNull():
# logging.debug("Error converting logo")
# else:
# icon.convertToFormat(QImage.Format_ARGB32)
# icon_bytes = icon.bits().asstring(icon.byteCount())
# icon_struct = (
# icon.width(),
# icon.height(),
# icon.bytesPerLine(),
# icon.hasAlphaChannel(),
# 32,
# 4,
# dbus.ByteArray(icon_bytes)
# )
# n.set_hint('icon_data', icon_struct)
# n.set_timeout(5000)
n.show()
else:
_Toast(title, msg)
示例3: display_song
def display_song(self):
"""Display the song data using notify-send."""
if self.get_data("status") == "playing":
# Create our temporary file if it doesn't exist yet.
open("/tmp/cmus_desktop_last_track", "a").write("4")
# Check to see when we got our last track from cmus.
last_notice = open("/tmp/cmus_desktop_last_track", "r").read()
# Write time stamp for current track from cmus.
last_notice_time = str(time.time())
open("/tmp/cmus_desktop_last_track", "w").write(last_notice_time)
# Calculate seconds between track changes.
track_change_duration = round(time.time() - float(last_notice))
# Display current track notification only if 5 seconds have
# elapsed since last track was chosen.
if track_change_duration > 5:
# Execute notify2 to create the notification
notify2.init("cmus-display")
text_body = self.format_notification_body()
# Check if we have a notify_body to avoid
# putting a "by" at the end
if text_body:
notification = notify2.Notification(
"Cmustify - current song", text_body, "")
notification.set_urgency(notify2.URGENCY_LOW)
notification.show()
return True
else:
return False
示例4: daemon
def daemon(args=None, daemon=None):
"""
Execute udiskie as a daemon.
"""
import gobject
import udiskie.automount
import udiskie.mount
import udiskie.prompt
parser = mount_program_options()
parser.add_option('-s', '--suppress', action='store_true',
dest='suppress_notify', default=False,
help='suppress popup notifications')
parser.add_option('-t', '--tray', action='store_true',
dest='tray', default=False,
help='show tray icon')
options, posargs = parser.parse_args(args)
logging.basicConfig(level=options.log_level, format='%(message)s')
mainloop = gobject.MainLoop()
# connect udisks
if daemon is None:
daemon = udisks_service(options.udisks_version).Daemon()
# create a mounter
prompt = udiskie.prompt.password(options.password_prompt)
filter = load_filter(options.filters)
mounter = udiskie.mount.Mounter(filter=filter, prompt=prompt, udisks=daemon)
# notifications (optional):
if not options.suppress_notify:
import udiskie.notify
try:
import notify2 as notify_service
except ImportError:
import pynotify as notify_service
notify_service.init('udiskie.mount')
notify = udiskie.notify.Notify(notify_service)
daemon.connect(notify)
# tray icon (optional):
if options.tray:
import udiskie.tray
create_menu = partial(udiskie.tray.create_menu,
udisks=daemon,
mounter=mounter,
actions={'quit': mainloop.quit})
statusicon = udiskie.tray.create_statusicon()
connection = udiskie.tray.connect_statusicon(statusicon, create_menu)
# automounter
automount = udiskie.automount.AutoMounter(mounter)
daemon.connect(automount)
mounter.mount_all()
try:
return mainloop.run()
except KeyboardInterrupt:
return 0
示例5: process
def process(self, message: Message):
"""Displays desktop notification about specified message.
:param message: E-Mail message object.
"""
print(" - {}: {}.process()".format(self.name, self.__class__.__name__))
notify2.init("Sendmail")
title = self.title_template.format(
subject=message.get("Subject"),
from_email=message.get("From"),
appname="Sendmail",
name=self.name
)
text = self.text_template.format(
subject=message.get("Subject"),
from_email=message.get("From"),
text=message.as_string(),
appname="Sendmail",
name=self.name
)
n = notify2.Notification(title,
text,
self.icon_name
)
n.show()
示例6: display_notification
def display_notification(title, message):
notify2.init("Init")
notice = notify2.Notification(title, message)
notice.show()
sleep(4)
notice.close()
return
示例7: main
def main():
notify2.init('git-watcher')
n = notify2.Notification("Git watcher started", os.getcwd(), "notification-message-im")
n.show()
while True:
run_check()
time.sleep(600)
示例8: view_notify
def view_notify(data):
""" Notify for Informer service. """
n = notify2.Notification("Incoming call", data)
n.set_hint("x", 200)
n.set_hint("y", 400)
notify2.init("informer")
n.show()
示例9: notify
def notify():
icon_path = "/home/dushyant/Desktop/Github/Weather-Notifier/weathernotifier/Weather-icon.png"
place = get_location()
resp = get_weather(place)
print resp
result = ''
result += "Place : " + str(resp[0]["Place"])
result += "\nStatus : " + str(resp[6])
result += "\nCurrent Temperature (Celcius) : " + str(resp[1]["temp"])
result += "\nMax Temperature (Celcius) : " + str(resp[1]["temp_max"])
result += "\nMin Temperature (Celcius) : " + str(resp[1]["temp_min"])
result += "\nWind Speed (m/s) : " + str(resp[2]["speed"])
result += "\nHumidity (%) : " + str(resp[3])
result += "\nPressure (hpa) : " + str(resp[4]["press"])
result += "\nCloud Cover (%) : " + str(resp[5])
# print result
# Notification Tool
notify2.init("Weather Notifier")
n = notify2.Notification("Weather Details", icon=icon_path)
n.update("Weather Details", result)
n.show()
示例10: main
def main():
notify2.init ('kremote')
signal.signal(signal.SIGINT,terminate)
parser = argparse.ArgumentParser(description='kremote daemon.')
parser.add_argument('-D','--daemon', dest='cmdline', required=True,
help='Command line to start the remote daemon')
parser.add_argument('-v','--version', action='version', version='kremote daemon 1')
args = parser.parse_args()
print args.cmdline
fd = launch_daemon(args.cmdline.split(' '))
shift = False
while True:
buf = read(fd,1)
if len(buf)==0:
break
if buf == 's':
shift = not shift
print '->', buf
action(buf, shift)
notify('Device listener failure',1)
exit(2)
示例11: __init__
def __init__(self, parent=None):
super(ScudCloud, self).__init__(parent)
self.setWindowTitle('ScudCloud')
notify2.init(self.APP_NAME)
self.settings = QSettings(expanduser("~")+"/.scudcloud", QSettings.IniFormat)
self.identifier = self.settings.value("Domain")
if Unity is not None:
self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop")
else:
self.launcher = DummyLauncher(self)
self.leftPane = LeftPane(self)
self.cookiesjar = PersistentCookieJar(self)
webView = Wrapper(self)
webView.page().networkAccessManager().setCookieJar(self.cookiesjar)
self.stackedWidget = QtGui.QStackedWidget()
self.stackedWidget.addWidget(webView)
centralWidget = QtGui.QWidget(self)
layout = QtGui.QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
layout.addWidget(self.leftPane)
layout.addWidget(self.stackedWidget)
centralWidget.setLayout(layout)
self.setCentralWidget(centralWidget)
self.addMenu()
self.tray = Systray(self)
self.systray()
self.installEventFilter(self)
self.zoom()
if self.identifier is None:
webView.load(QtCore.QUrl(self.SIGNIN_URL))
else:
webView.load(QtCore.QUrl(self.domain()))
webView.show()
示例12: __init__
def __init__(self, appName, timeout, guiApp):
super(MessengerLinux, self).__init__(timeout)
notify2.init(appName, guiApp.eventLoop)
self.notification = None
if guiApp.iconPath:
self.icon = guiApp.getNotificationIcon()
示例13: initialize
def initialize(self, context):
if sys.platform != 'linux2':
raise ResultProcessorError('Notifications are only supported in linux')
if not notify2:
raise ResultProcessorError('notify2 not installed. Please install the notify2 package')
notify2.init("Workload Automation")
示例14: notify
def notify(self):
''' Displays a notification via libnotify '''
import notify2
notify2.init (self.title)
noti = notify2.Notification (self.title,
self.message,
"dialog-information")
noti.show ()
示例15: show
def show(content):
try:
import notify2
notify2.init('Slx7hS3ns3on')
notify = notify2.Notification('Slx7hS3ns3on', content, "dialog-information")
notify.show()
except:
print("**** Requires notify. sudo pip install notify2.")