From 4671c002c979cfd1287a34e229de5679f1979c4a Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 2 Nov 2023 12:48:21 +0100 Subject: [PATCH] qt: fix detected account select (#8673) --- electrum/gui/qt/util.py | 9 +++++++++ electrum/gui/qt/wizard/wallet.py | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qt/util.py b/electrum/gui/qt/util.py index 3775b1875..0aa441f1c 100644 --- a/electrum/gui/qt/util.py +++ b/electrum/gui/qt/util.py @@ -471,6 +471,8 @@ class ChoiceWidget(QWidget): self.selected_index = -1 self.selected_item = None + self.selected_key = None + self.choices = choices if message and len(message) > 50: @@ -498,8 +500,15 @@ class ChoiceWidget(QWidget): def on_selected(self, button): self.selected_index = self.group.id(button) self.selected_item = self.choices[self.selected_index] + self.selected_key = self.choices[self.selected_index][0] self.itemSelected.emit(self.selected_index) + def select(self, key): + iterator = enumerate(self.choices) + for i, c in iterator: + if key == c[0]: + self.group.button(i).click() + def address_field(addresses): hbox = QHBoxLayout() diff --git a/electrum/gui/qt/wizard/wallet.py b/electrum/gui/qt/wizard/wallet.py index f0e8a5b09..cc20594bd 100644 --- a/electrum/gui/qt/wizard/wallet.py +++ b/electrum/gui/qt/wizard/wallet.py @@ -700,9 +700,7 @@ class WCScriptAndDerivation(WizardComponent, Logger): script_type = account["script_type"] if script_type == "p2pkh": script_type = "standard" - button_index = self.c_values.index(script_type) - button = self.clayout.group.buttons()[button_index] - button.setChecked(True) + self.choice_w.select(script_type) self.derivation_path_edit.setText(account["derivation_path"]) button.clicked.connect(lambda: Bip39RecoveryDialog(self, get_account_xpub, on_account_select))