diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index f44183070..345163260 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -221,9 +221,8 @@ class ElectrumGui(PrintError): wallet = self.daemon.load_wallet(path, None) except BaseException as e: traceback.print_exc(file=sys.stdout) - d = QMessageBox(QMessageBox.Warning, _('Error'), - _('Cannot load wallet') + ' (1):\n' + str(e)) - d.exec_() + QMessageBox.warning(None, _('Error'), + _('Cannot load wallet') + ' (1):\n' + str(e)) # if app is starting, still let wizard to appear if not app_is_starting: return @@ -233,29 +232,27 @@ class ElectrumGui(PrintError): return # create or raise window try: - for w in self.windows: - if w.wallet.storage.path == wallet.storage.path: + for window in self.windows: + if window.wallet.storage.path == wallet.storage.path: break else: - w = self._create_window_for_wallet(wallet) + window = self._create_window_for_wallet(wallet) except BaseException as e: traceback.print_exc(file=sys.stdout) - d = QMessageBox(QMessageBox.Warning, _('Error'), - _('Cannot create window for wallet') + ':\n' + str(e)) - d.exec_() + QMessageBox.warning(None, _('Error'), + _('Cannot create window for wallet') + ':\n' + str(e)) if app_is_starting: wallet_dir = os.path.dirname(path) path = os.path.join(wallet_dir, get_new_wallet_name(wallet_dir)) self.start_new_window(path, uri) return if uri: - w.pay_to_URI(uri) - w.bring_to_top() - w.setWindowState(w.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) + window.pay_to_URI(uri) + window.bring_to_top() + window.setWindowState(window.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) - # this will activate the window - w.activateWindow() - return w + window.activateWindow() + return window def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wallet]: wizard = InstallWizard(self.config, self.app, self.plugins) @@ -274,9 +271,8 @@ class ElectrumGui(PrintError): return e.wallet except (WalletFileException, BitcoinException) as e: traceback.print_exc(file=sys.stderr) - d = QMessageBox(QMessageBox.Warning, _('Error'), - _('Cannot load wallet') + ' (2):\n' + str(e)) - d.exec_() + QMessageBox.warning(None, _('Error'), + _('Cannot load wallet') + ' (2):\n' + str(e)) return finally: wizard.terminate() diff --git a/electrum/gui/qt/installwizard.py b/electrum/gui/qt/installwizard.py index 1538bc9db..3a2da6271 100644 --- a/electrum/gui/qt/installwizard.py +++ b/electrum/gui/qt/installwizard.py @@ -212,32 +212,28 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): traceback.print_exc(file=sys.stderr) self.temp_storage = None self.next_button.setEnabled(False) + user_needs_to_enter_password = False if self.temp_storage: if not self.temp_storage.file_exists(): msg =_("This file does not exist.") + '\n' \ + _("Press 'Next' to create this wallet, or choose another file.") - pw = False elif not wallet_from_memory: if self.temp_storage.is_encrypted_with_user_pw(): msg = _("This file is encrypted with a password.") + '\n' \ + _('Enter your password or choose another file.') - pw = True + user_needs_to_enter_password = True elif self.temp_storage.is_encrypted_with_hw_device(): msg = _("This file is encrypted using a hardware device.") + '\n' \ + _("Press 'Next' to choose device to decrypt.") - pw = False else: msg = _("Press 'Next' to open this wallet.") - pw = False else: msg = _("This file is already open in memory.") + "\n" \ + _("Press 'Next' to create/focus window.") - pw = False else: msg = _('Cannot read file') - pw = False self.msg_label.setText(msg) - if pw: + if user_needs_to_enter_password: self.pw_label.show() self.pw_e.show() self.pw_e.setFocus()