diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index d7ce7cc08..4d0e989b2 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -29,7 +29,6 @@ import PyQt4 from PyQt4.QtGui import * from PyQt4.QtCore import * import PyQt4.QtCore as QtCore -print PyQt4.QtCore.PYQT_VERSION_STR from electrum.bitcoin import MIN_RELAY_TX_FEE, is_valid from electrum.plugins import run_hook @@ -856,7 +855,7 @@ class ElectrumWindow(QMainWindow): 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: QMessageBox.warning(self, _('Error'), msg, _('OK')) - WaitingDialog(self, 'Broadcasting..').start(broadcast_thread, broadcast_done) + WaitingDialog(self, 'Broadcasting..',broadcast_thread, broadcast_done).start() diff --git a/gui/qt/util.py b/gui/qt/util.py index 11ddf6fb0..0c8334bc6 100644 --- a/gui/qt/util.py +++ b/gui/qt/util.py @@ -6,26 +6,24 @@ import time import threading -class WaitingDialog(QDialog): - def __init__(self, parent, message): - QDialog.__init__(self, parent) - self.setWindowTitle('Please wait') +class WaitingDialog(QThread): + def __init__(self, parent, message, run_task, on_complete=None): + QThread.__init__(self) + self.d = QDialog(parent) + self.d.setWindowTitle('Please wait') l = QLabel(message) - vbox = QVBoxLayout(self) + vbox = QVBoxLayout(self.d) vbox.addWidget(l) - self.show() - - def start(self, run_thread, on_complete=None): - def my_thread(): - self.result = run_thread() - self.emit(SIGNAL('done')) - self.accept() - + self.run_task = run_task if on_complete: - self.connect(self, SIGNAL('done'), lambda: on_complete(*self.result)) - - threading.Thread(target=my_thread).start() + self.d.connect(self.d, SIGNAL('done'), lambda: on_complete(*self.result)) + self.d.show() + def run(self): + self.result = self.run_task() + self.d.emit(SIGNAL('done')) + self.d.accept() + class Timer(QThread): @@ -186,5 +184,5 @@ class MyTreeWidget(QTreeWidget): if __name__ == "__main__": 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_()