mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
add preprocessing to ThreadedButton
This commit is contained in:
parent
f50e56d229
commit
acf4ad5ec8
1 changed files with 5 additions and 1 deletions
|
@ -73,8 +73,9 @@ class EnterButton(QPushButton):
|
||||||
|
|
||||||
|
|
||||||
class ThreadedButton(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)
|
QPushButton.__init__(self, text)
|
||||||
|
self.before = before
|
||||||
self.run_task = func
|
self.run_task = func
|
||||||
self.on_success = on_success
|
self.on_success = on_success
|
||||||
self.clicked.connect(self.do_exec)
|
self.clicked.connect(self.do_exec)
|
||||||
|
@ -95,12 +96,15 @@ class ThreadedButton(QPushButton):
|
||||||
try:
|
try:
|
||||||
self.result = self.run_task()
|
self.result = self.run_task()
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
|
traceback.print_exc(file=sys.stdout)
|
||||||
self.error = str(e.message)
|
self.error = str(e.message)
|
||||||
self.emit(SIGNAL('error'))
|
self.emit(SIGNAL('error'))
|
||||||
return
|
return
|
||||||
self.emit(SIGNAL('done'))
|
self.emit(SIGNAL('done'))
|
||||||
|
|
||||||
def do_exec(self):
|
def do_exec(self):
|
||||||
|
if self.before:
|
||||||
|
self.before()
|
||||||
t = threading.Thread(target=self.do_func)
|
t = threading.Thread(target=self.do_func)
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
|
Loading…
Add table
Reference in a new issue