commit acf4ad5ec856e20256ed99f0377304ce22cdce99
parent f50e56d229964eb4cd4b11f0eb7b5c4300fafe2e
Author: ThomasV <thomasv@gitorious>
Date: Tue, 21 Apr 2015 11:00:40 +0200
add preprocessing to ThreadedButton
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/gui/qt/util.py b/gui/qt/util.py
@@ -73,8 +73,9 @@ class EnterButton(QPushButton):
class ThreadedButton(QPushButton):
- def __init__(self, text, func, on_success=None):
+ def __init__(self, text, func, on_success=None, before=None):
QPushButton.__init__(self, text)
+ self.before = before
self.run_task = func
self.on_success = on_success
self.clicked.connect(self.do_exec)
@@ -95,12 +96,15 @@ class ThreadedButton(QPushButton):
try:
self.result = self.run_task()
except BaseException as e:
+ traceback.print_exc(file=sys.stdout)
self.error = str(e.message)
self.emit(SIGNAL('error'))
return
self.emit(SIGNAL('done'))
def do_exec(self):
+ if self.before:
+ self.before()
t = threading.Thread(target=self.do_func)
t.setDaemon(True)
t.start()