tdo not expose network to wizard. update message in issue #1972 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 7ea91dde2eeb2b31980d909ba66cca7741eab20c DIR parent bab15a245bb2256222d9fb2b16035cf06aae3666 HTML Author: ThomasV <thomasv@electrum.org> Date: Fri, 14 Oct 2016 14:05:24 +0200 do not expose network to wizard. update message in issue #1972 Diffstat: M gui/kivy/main_window.py | 3 ++- M gui/kivy/uix/dialogs/installwizard… | 1 - M gui/qt/__init__.py | 23 +++++++++++++++-------- M gui/qt/installwizard.py | 31 +++++++++++++++---------------- M gui/qt/network_dialog.py | 2 +- M lib/base_wizard.py | 3 +-- 6 files changed, 34 insertions(+), 29 deletions(-) --- DIR diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py t@@ -410,6 +410,7 @@ class ElectrumWindow(App): def on_wizard_complete(self, instance, wallet): if wallet: + wallet.start_threads(self.daemon.network) self.daemon.add_wallet(wallet) self.load_wallet(wallet) self.on_resume() t@@ -425,7 +426,7 @@ class ElectrumWindow(App): self.on_resume() else: Logger.debug('Electrum: Wallet not found. Launching install wizard') - wizard = Factory.InstallWizard(self.electrum_config, self.network, path) + wizard = Factory.InstallWizard(self.electrum_config, path) wizard.bind(on_wizard_complete=self.on_wizard_complete) action = wizard.storage.get_action() wizard.run(action) DIR diff --git a/gui/kivy/uix/dialogs/installwizard.py b/gui/kivy/uix/dialogs/installwizard.py t@@ -759,7 +759,6 @@ class InstallWizard(BaseWizard, Widget): t.start() def terminate(self, **kwargs): - self.wallet.start_threads(self.network) self.dispatch('on_wizard_complete', self.wallet) def choice_dialog(self, **kwargs): DIR diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py t@@ -161,12 +161,11 @@ class ElectrumGui: else: wallet = self.daemon.load_wallet(path) if not wallet: - wizard = InstallWizard(self.config, self.app, self.plugins, self.daemon.network, path) + wizard = InstallWizard(self.config, self.app, self.plugins, path) wallet = wizard.run_and_get_wallet() if not wallet: return - #if wallet.get_action(): - # return + wallet.start_threads(self.daemon.network) self.daemon.add_wallet(wallet) w = self.create_window_for_wallet(wallet) if uri: t@@ -181,23 +180,31 @@ class ElectrumGui: self.config.save_last_wallet(window.wallet) run_hook('on_close_window', window) + def init_network(self): + # Show network dialog if config does not exist + if self.daemon.network: + if self.config.get('auto_connect') is None: + wizard = InstallWizard(self.config, self.app, self.plugins, None) + wizard.init_network(self.daemon.network) + wizard.terminate() + def main(self): + try: + self.init_network() + except: + traceback.print_exc(file=sys.stdout) + return self.timer.start() self.config.open_last_wallet() path = self.config.get_wallet_path() if not self.start_new_window(path, self.config.get('url')): return - signal.signal(signal.SIGINT, lambda *args: self.app.quit()) - # main loop self.app.exec_() - # Shut down the timer cleanly self.timer.stop() - # clipboard persistence. see http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg17328.html event = QtCore.QEvent(QtCore.QEvent.Clipboard) self.app.sendEvent(self.app.clipboard(), event) - self.tray.hide() DIR diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py t@@ -95,9 +95,9 @@ def wizard_dialog(func): # WindowModalDialog must come first as it overrides show_error class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): - def __init__(self, config, app, plugins, network, storage): + def __init__(self, config, app, plugins, storage): - BaseWizard.__init__(self, config, network, storage) + BaseWizard.__init__(self, config, storage) QDialog.__init__(self, None) self.setWindowTitle('Electrum - ' + _('Install Wizard')) t@@ -146,10 +146,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): self.refresh_gui() # Need for QT on MacOSX. Lame. def run_and_get_wallet(self): - # Show network dialog if config does not exist - if self.network: - if self.config.get('auto_connect') is None: - self.choose_server(self.network) path = self.storage.path if self.storage.requires_split(): t@@ -337,7 +333,6 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): self.run(action) def terminate(self): - self.wallet.start_threads(self.network) self.emit(QtCore.SIGNAL('accept')) def waiting_dialog(self, task, msg): t@@ -391,25 +386,29 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): self.set_main_layout(vbox, _('Master Public Key')) return None - def choose_server(self, network): - title = _("Electrum communicates with remote servers to get " + def init_network(self, network): + message = _("Electrum communicates with remote servers to get " "information about your transactions and addresses. The " "servers all fulfil the same purpose only differing in " "hardware. In most cases you simply want to let Electrum " "pick one at random. However if you prefer feel free to " "select a server manually.") choices = [_("Auto connect"), _("Select server manually")] - choices_title = _("How do you want to connect to a server? ") - clayout = ChoicesLayout(choices_title, choices) + title = _("How do you want to connect to a server? ") + clayout = ChoicesLayout(message, choices) self.set_main_layout(clayout.layout(), title) - auto_connect = True - if clayout.selected_index() == 1: + r = clayout.selected_index() + if r == 0: + auto_connect = True + elif r == 1: + auto_connect = True nlayout = NetworkChoiceLayout(network, self.config, wizard=True) - if self.set_main_layout(nlayout.layout(), raise_on_cancel=False): - nlayout.accept() + if self.set_main_layout(nlayout.layout()): auto_connect = False - self.config.set_key('auto_connect', auto_connect, True) + else: + auto_connect = True network.auto_connect = auto_connect + self.config.set_key('auto_connect', auto_connect, True) @wizard_dialog def multisig_dialog(self, run_next): DIR diff --git a/gui/qt/network_dialog.py b/gui/qt/network_dialog.py t@@ -73,7 +73,7 @@ class NetworkChoiceLayout(object): else: status += "\n" + _("Disconnected from server") else: - status = _("Please choose a server.") + "\n" + _("Select 'Cancel' if you are offline.") + status = _("Please choose a server.") + "\n" + _("Press 'Next' if you are offline.") vbox = QVBoxLayout() hbox = QHBoxLayout() DIR diff --git a/lib/base_wizard.py b/lib/base_wizard.py t@@ -32,10 +32,9 @@ from plugins import run_hook class BaseWizard(object): - def __init__(self, config, network, path): + def __init__(self, config, path): super(BaseWizard, self).__init__() self.config = config - self.network = network self.storage = WalletStorage(path) self.wallet = None self.stack = []