mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
rewrite WaiingDialog as child class of QThread
This commit is contained in:
parent
13fa81a90e
commit
40b3b47d5b
2 changed files with 17 additions and 20 deletions
|
@ -29,7 +29,6 @@ import PyQt4
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import PyQt4.QtCore as QtCore
|
import PyQt4.QtCore as QtCore
|
||||||
print PyQt4.QtCore.PYQT_VERSION_STR
|
|
||||||
|
|
||||||
from electrum.bitcoin import MIN_RELAY_TX_FEE, is_valid
|
from electrum.bitcoin import MIN_RELAY_TX_FEE, is_valid
|
||||||
from electrum.plugins import run_hook
|
from electrum.plugins import run_hook
|
||||||
|
@ -856,7 +855,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
self.broadcast_transaction(tx)
|
self.broadcast_transaction(tx)
|
||||||
|
|
||||||
WaitingDialog(self, 'Signing..').start(sign_thread, sign_done)
|
WaitingDialog(self, 'Signing..', sign_thread, sign_done).start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -878,7 +877,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
else:
|
else:
|
||||||
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
||||||
|
|
||||||
WaitingDialog(self, 'Broadcasting..').start(broadcast_thread, broadcast_done)
|
WaitingDialog(self, 'Broadcasting..',broadcast_thread, broadcast_done).start()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,25 +6,23 @@ import time
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
class WaitingDialog(QDialog):
|
class WaitingDialog(QThread):
|
||||||
def __init__(self, parent, message):
|
def __init__(self, parent, message, run_task, on_complete=None):
|
||||||
QDialog.__init__(self, parent)
|
QThread.__init__(self)
|
||||||
self.setWindowTitle('Please wait')
|
self.d = QDialog(parent)
|
||||||
|
self.d.setWindowTitle('Please wait')
|
||||||
l = QLabel(message)
|
l = QLabel(message)
|
||||||
vbox = QVBoxLayout(self)
|
vbox = QVBoxLayout(self.d)
|
||||||
vbox.addWidget(l)
|
vbox.addWidget(l)
|
||||||
self.show()
|
self.run_task = run_task
|
||||||
|
|
||||||
def start(self, run_thread, on_complete=None):
|
|
||||||
def my_thread():
|
|
||||||
self.result = run_thread()
|
|
||||||
self.emit(SIGNAL('done'))
|
|
||||||
self.accept()
|
|
||||||
|
|
||||||
if on_complete:
|
if on_complete:
|
||||||
self.connect(self, SIGNAL('done'), lambda: on_complete(*self.result))
|
self.d.connect(self.d, SIGNAL('done'), lambda: on_complete(*self.result))
|
||||||
|
self.d.show()
|
||||||
|
|
||||||
threading.Thread(target=my_thread).start()
|
def run(self):
|
||||||
|
self.result = self.run_task()
|
||||||
|
self.d.emit(SIGNAL('done'))
|
||||||
|
self.d.accept()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -186,5 +184,5 @@ class MyTreeWidget(QTreeWidget):
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
WaitingDialog(None, 'testing ...').start(lambda: [time.sleep(1)], lambda x: QMessageBox.information(None, 'done', "done", _('OK')))
|
WaitingDialog(None, 'testing ...', lambda: [time.sleep(1)], lambda x: QMessageBox.information(None, 'done', "done", _('OK'))).start()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
Loading…
Add table
Reference in a new issue