parent
491e5d73c3
commit
100e40c0bf
1 changed files with 11 additions and 7 deletions
18
toast.py
18
toast.py
|
@ -5,9 +5,8 @@ from PyQt4 import QtGui, QtCore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pynotify
|
import pynotify
|
||||||
pynote = True
|
|
||||||
except:
|
except:
|
||||||
pynote = False
|
pynotify = None
|
||||||
|
|
||||||
class DefaultToast(object):
|
class DefaultToast(object):
|
||||||
def __init__(self, title, msg, icon):
|
def __init__(self, title, msg, icon):
|
||||||
|
@ -84,9 +83,12 @@ class ToastMachine(object):
|
||||||
if self in self.parent.toasts:
|
if self in self.parent.toasts:
|
||||||
self.parent.toasts.remove(self)
|
self.parent.toasts.remove(self)
|
||||||
|
|
||||||
def __init__(self, parent, name, type="default", types={'default' : DefaultToast,
|
def __init__(self, parent, name, type="default", types=({'default' : DefaultToast,
|
||||||
'libnotify': pynotify.Notification},
|
'libnotify': pynotify.Notification}
|
||||||
|
if pynotify else
|
||||||
|
{'default' : DefaultToast}),
|
||||||
extras={}):
|
extras={}):
|
||||||
|
print types
|
||||||
self.mainwindow = parent
|
self.mainwindow = parent
|
||||||
self.name = name
|
self.name = name
|
||||||
types.update(extras)
|
types.update(extras)
|
||||||
|
@ -96,7 +98,7 @@ class ToastMachine(object):
|
||||||
|
|
||||||
if type == "libnotify":
|
if type == "libnotify":
|
||||||
try:
|
try:
|
||||||
if not pynote or not pynotify.init("ToastMachine"):
|
if not pynotify or not pynotify.init("ToastMachine"):
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
print "Problem initilizing pynotify"
|
print "Problem initilizing pynotify"
|
||||||
|
@ -174,8 +176,10 @@ class PesterToast(QtGui.QFrame, DefaultToast):
|
||||||
|
|
||||||
class PesterToastMachine(ToastMachine, QtCore.QObject):
|
class PesterToastMachine(ToastMachine, QtCore.QObject):
|
||||||
def __init__(self, parent, name, type="default",
|
def __init__(self, parent, name, type="default",
|
||||||
types={'default' : DefaultToast,
|
types=({'default' : DefaultToast,
|
||||||
'libnotify': pynotify.Notification},
|
'libnotify' : pynotify.Notification}
|
||||||
|
if pynotify else
|
||||||
|
{'default' : DefaultToast}),
|
||||||
extras={}):
|
extras={}):
|
||||||
ToastMachine.__init__(self, parent, name, type, types, extras)
|
ToastMachine.__init__(self, parent, name, type, types, extras)
|
||||||
QtCore.QObject.__init__(self, parent)
|
QtCore.QObject.__init__(self, parent)
|
||||||
|
|
Loading…
Reference in a new issue