From 11acefa07621a5b0fa1332fb3238e0b1f1b6cf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Wed, 18 Nov 2020 16:32:29 +0100 Subject: [PATCH] Fix quit script action --- examples/mail.py | 2 +- examples/picture.py | 14 +++++++++----- examples/timer.py | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) 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)