From c58ff7caecb3138f63e3d08aa770069f36e36c53 Mon Sep 17 00:00:00 2001 From: f321x Date: Mon, 16 Jun 2025 10:08:11 +0200 Subject: [PATCH] qt: wrap show_bitcoin_paper() in WaitingDialog i noticed that the `show_bitcoin_paper()` call can be a bit slow on some machines blocking the gui for multiple seconds without giving feedback. Wrapping it in a waiting dialog gives the user some feedback that something is happening. --- electrum/gui/qt/main_window.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 42db75734..05600c3c7 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -874,13 +874,22 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): def show_bitcoin_paper(self): filename = os.path.join(self.config.path, 'bitcoin.pdf') if not os.path.exists(filename): - s = self._fetch_tx_from_network("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713") - if not s: - return - s = s.split("0100000000000000")[1:-1] - out = ''.join(x[6:136] + x[138:268] + x[270:400] if len(x) > 136 else x[6:] for x in s)[16:-20] - with open(filename, 'wb') as f: - f.write(bytes.fromhex(out)) + def fetch_bitcoin_paper(): + s = self._fetch_tx_from_network("54e48e5f5c656b26c3bca14a8c95aa583d07ebe84dde3b7dd4a78f4e4186e713") + if not s: + return + s = s.split("0100000000000000")[1:-1] + out = ''.join(x[6:136] + x[138:268] + x[270:400] if len(x) > 136 else x[6:] for x in s)[16:-20] + with open(filename, 'wb') as f: + f.write(bytes.fromhex(out)) + WaitingDialog( + self, + _("Fetching Bitcoin Paper..."), + fetch_bitcoin_paper, + on_success=lambda _: webopen('file:///' + filename), + on_error=self.on_error, + ) + return webopen('file:///' + filename) def show_update_check(self, version=None):