electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 2a53e85e8d4ecb4bcebecfde1b34826bc4e88578
parent 064b59c65edd9e51758335ba6e46422f2ba01a52
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 29 Jun 2017 18:23:10 +0200

fix #2452

Diffstat:
Mgui/qt/installwizard.py | 93+++++++++++++++++++++++++++++++++++++++++++------------------------------------
1 file changed, 51 insertions(+), 42 deletions(-)

diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -147,63 +147,73 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): def run_and_get_wallet(self): - def on_filename(): + vbox = QVBoxLayout() + hbox = QHBoxLayout() + hbox.addWidget(QLabel(_('Wallet') + ':')) + self.name_e = QLineEdit() + hbox.addWidget(self.name_e) + button = QPushButton(_('Choose...')) + hbox.addWidget(button) + vbox.addLayout(hbox) + + self.msg_label = QLabel('') + vbox.addWidget(self.msg_label) + hbox2 = QHBoxLayout() + self.pw_e = QLineEdit('', self) + self.pw_e.setFixedWidth(150) + self.pw_e.setEchoMode(2) + self.pw_label = QLabel(_('Password') + ':') + hbox2.addWidget(self.pw_label) + hbox2.addWidget(self.pw_e) + hbox2.addStretch() + vbox.addLayout(hbox2) + self.set_layout(vbox, title=_('Electrum wallet')) + + def on_choose(): wallet_folder = os.path.dirname(self.storage.path) path = unicode(QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder)) if path: self.name_e.setText(path) - self.storage = WalletStorage(path) - update_layout() - def update_layout(): - name = os.path.basename(self.storage.path) - vbox = QVBoxLayout() - hbox = QHBoxLayout() - hbox.addWidget(QLabel(_('Wallet') + ':')) - self.name_e = QLineEdit(text=name) - hbox.addWidget(self.name_e) - button = QPushButton(_('Choose...')) - button.clicked.connect(on_filename) - hbox.addWidget(button) - vbox.addLayout(hbox) - self.pw_e = None - if not self.storage.file_exists(): - msg = _("This file does not exist.") + '\n' \ - + _("Press 'Next' to create this wallet, or chose another file.") - vbox.addWidget(QLabel(msg)) - - elif self.storage.file_exists() and self.storage.is_encrypted(): - msg = _("This file is encrypted.") + '\n' + _('Enter your password or choose another file.') - vbox.addWidget(QLabel(msg)) - hbox2 = QHBoxLayout() - self.pw_e = QLineEdit('', self) - self.pw_e.setFixedWidth(150) - self.pw_e.setEchoMode(2) - hbox2.addWidget(QLabel(_('Password') + ':')) - hbox2.addWidget(self.pw_e) - hbox2.addStretch() - vbox.addLayout(hbox2) + def on_filename(path): + try: + self.storage = WalletStorage(unicode(path)) + except IOError: + self.storage = None + if self.storage: + if not self.storage.file_exists(): + msg =_("This file does not exist.") + '\n' \ + + _("Press 'Next' to create this wallet, or choose another file.") + pw = False + elif self.storage.file_exists() and self.storage.is_encrypted(): + msg = _("This file is encrypted.") + '\n' + _('Enter your password or choose another file.') + pw = True + else: + msg = _("Press 'Next' to open this wallet.") + pw = False else: - msg = _("Press 'Next' to open this wallet.") - vbox.addWidget(QLabel(msg)) - - self.set_layout(vbox, title=_('Electrum wallet')) - if self.pw_e: + msg = _('Cannot read file') + pw = False + self.msg_label.setText(msg) + if pw: + self.pw_label.show() self.pw_e.show() self.pw_e.setFocus() + else: + self.pw_label.hide() + self.pw_e.hide() - while True: - update_layout() + button.clicked.connect(on_choose) + self.name_e.textChanged.connect(on_filename) + self.name_e.setText(os.path.basename(self.storage.path)) + while True: if self.storage.file_exists() and not self.storage.is_encrypted(): break - if not self.loop.exec_(): return - if not self.storage.file_exists(): break - if self.storage.file_exists() and self.storage.is_encrypted(): password = unicode(self.pw_e.text()) try: @@ -217,7 +227,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): QMessageBox.information(None, _('Error'), str(e), _('OK')) return - path = self.storage.path if self.storage.requires_split(): self.hide()