tgive user the option to remove incomplete wallet - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 7e6bd2eb8c139fe3711fe84a4fa87e917bbbf097 DIR parent 9aa812026a62d22a230746c87a75284afc8d6af0 HTML Author: ThomasV <thomasv@gitorious> Date: Fri, 3 Apr 2015 13:10:43 +0200 give user the option to remove incomplete wallet Diffstat: M gui/qt/__init__.py | 31 +++++++++++++++++++++---------- M gui/qt/main_window.py | 14 +------------- M gui/qt/util.py | 3 ++- 3 files changed, 24 insertions(+), 24 deletions(-) --- DIR diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py t@@ -142,10 +142,29 @@ class ElectrumGui: qtVersion = qVersion() return int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7 - def set_url(self, uri): self.current_window.pay_from_URI(uri) + def run_wizard(self, storage, action): + import installwizard + if storage.file_exists and action != 'new': + msg = _("The file '%s' contains an incompletely created wallet.")%storage.path + '\n'\ + + _("Do you want to complete its creation now?") + if not util.question(msg): + if util.question(_("Do you want to delete '%s'?")%storage.path): + os.remove(storage.path) + QMessageBox.information(None, _('Warning'), _('The file was removed'), _('OK')) + return + return + wizard = installwizard.InstallWizard(self.config, self.network, storage) + wizard.show() + try: + wallet = wizard.run(action) + except BaseException as e: + traceback.print_exc(file=sys.stdout) + QMessageBox.information(None, _('Error'), str(e), _('OK')) + return + return wallet def main(self, url): t@@ -171,15 +190,7 @@ class ElectrumGui: action = 'new' if action is not None: - import installwizard - wizard = installwizard.InstallWizard(self.config, self.network, storage) - wizard.show() - try: - wallet = wizard.run(action) - except BaseException as e: - traceback.print_exc(file=sys.stdout) - QMessageBox.information(None, _('Error'), str(e), _('OK')) - return + wallet = self.run_wizard(storage, action) if not wallet: return else: DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py t@@ -268,22 +268,10 @@ class ElectrumWindow(QMainWindow): QMessageBox.warning(None, _('Warning'), str(e), _('OK')) return action = wallet.get_action() - # ask for confirmation - if action is not None: - if not self.question(_("This file contains an incompletely created wallet.\nDo you want to complete its creation now?")): - return self.hide() # run wizard if action is not None: - import installwizard - wizard = installwizard.InstallWizard(self.config, self.network, storage) - wizard.show() - try: - wallet = wizard.run(action) - except BaseException as e: - traceback.print_exc(file=sys.stdout) - QMessageBox.information(None, _('Error'), str(e), _('OK')) - return + wallet = self.gui_object.run_wizard(storage, action) if not wallet: self.show() return DIR diff --git a/gui/qt/util.py b/gui/qt/util.py t@@ -187,7 +187,8 @@ def text_dialog(parent, title, label, ok_label, default=None): if dialog.exec_(): return unicode(txt.toPlainText()) - +def question(msg): + return QMessageBox.question(None, _('Message'), msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes def address_field(addresses): hbox = QHBoxLayout()