Made the send_tx call for the lite gui asynchrone

This commit is contained in:
Maran 2012-11-22 19:33:13 +01:00
parent d68fcf9884
commit be9a64fef3
1 changed files with 29 additions and 3 deletions

View File

@ -4,6 +4,8 @@ import sys
try: try:
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
import PyQt4.QtCore as QtCore
except ImportError: except ImportError:
print "You need to have PyQT installed to run Electrum in graphical mode." print "You need to have PyQT installed to run Electrum in graphical mode."
print "If you have pip installed try 'sudo pip install pyqt' if you are on Debian/Ubuntu try 'sudo apt-get install python-qt4'." print "If you have pip installed try 'sudo pip install pyqt' if you are on Debian/Ubuntu try 'sudo apt-get install python-qt4'."
@ -711,6 +713,25 @@ class MiniActuator:
receive_popup.setup(copied_address) receive_popup.setup(copied_address)
receive_popup.popup() receive_popup.popup()
def waiting_dialog(self, f):
s = Timer()
s.start()
w = QDialog()
w.resize(200, 70)
w.setWindowTitle('Electrum')
l = QLabel('Sending transaction, please wait.')
vbox = QVBoxLayout()
vbox.addWidget(l)
w.setLayout(vbox)
w.show()
def ff():
s = f()
if s: l.setText(s)
else: w.close()
w.connect(s, QtCore.SIGNAL('timersignal'), ff)
w.exec_()
w.destroy()
def send(self, address, amount, parent_window): def send(self, address, amount, parent_window):
"""Send bitcoins to the target address.""" """Send bitcoins to the target address."""
dest_address = self.fetch_destination(address) dest_address = self.fetch_destination(address)
@ -744,7 +765,12 @@ class MiniActuator:
QMessageBox.warning(parent_window, _('Error'), str(error), _('OK')) QMessageBox.warning(parent_window, _('Error'), str(error), _('OK'))
return False return False
status, message = self.wallet.sendtx(tx) h = self.wallet.send_tx(tx)
self.waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Sending transaction, please wait..."))
status, message = self.wallet.receive_tx(h)
if not status: if not status:
import tempfile import tempfile
dumpf = tempfile.NamedTemporaryFile(delete=False) dumpf = tempfile.NamedTemporaryFile(delete=False)
@ -755,7 +781,7 @@ class MiniActuator:
return False return False
QMessageBox.information(parent_window, '', QMessageBox.information(parent_window, '',
_('Payment sent.') + '\n' + message, _('OK')) _('Your transaction has been sent.') + '\n' + message, _('OK'))
return True return True
def fetch_destination(self, address): def fetch_destination(self, address):