diff --git a/examples/mail.py b/examples/mail.py index 3f493e0..885ceb0 100755 --- a/examples/mail.py +++ b/examples/mail.py @@ -178,7 +178,7 @@ class EventThread(Thread,GenericMonitor): def signalHandler(signal_received, frame): eventThread.stop() eventThread.join() - groups = {'groups':['Mail', 'Pidgin']} + groups = ['Mail', 'Pidgin'] eventThread.deleteGroups(groups) sys.exit(0) diff --git a/examples/picture.py b/examples/picture.py index 8b5291f..c54941e 100755 --- a/examples/picture.py +++ b/examples/picture.py @@ -29,10 +29,6 @@ import signal from genericmonitor import * -def signal_handler(sig, frame): - sys.exit(0) -signal.signal(signal.SIGINT, signal_handler) - class PicturePopup(GenericMonitor): def __init__(self): @@ -40,9 +36,11 @@ class PicturePopup(GenericMonitor): self.item = None self.imgs_idx = 0 self.setupMonitor() + + def run(self): self.display_next_img() self.runMainLoop() - + def display_next_img(self): filedata = urllib.request.urlopen('https://source.unsplash.com/random') # Get redirected URL without parameters @@ -91,4 +89,10 @@ class PicturePopup(GenericMonitor): self.deleteItems([self.item.getFullName()]) self.stopMainLoop() +def signal_handler(sig, frame): + picture.deleteGroups(['PicturePopup']) + sys.exit(0) +signal.signal(signal.SIGINT, signal_handler) + picture = PicturePopup() +picture.run() diff --git a/examples/timer.py b/examples/timer.py index 976409f..624ef81 100755 --- a/examples/timer.py +++ b/examples/timer.py @@ -113,7 +113,7 @@ class TimerThread(Thread,GenericMonitor): def signalHandler(signal_received, frame): timerThread.stop() timerThread.join() - groups = {'groups':['Timer']} + groups = ['Timer'] timerThread.deleteGroups(groups) sys.exit(0)