tuse QStackedLayout in install wizard - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit c8cd187bd4441a06e80d53f0ddaeed45589f187e DIR parent d8626793bc548a763741571e21131340ed2df48a HTML Author: ThomasV <thomasv@gitorious> Date: Sun, 3 Nov 2013 11:03:45 +0100 use QStackedLayout in install wizard Diffstat: M gui/qt/installwizard.py | 45 +++++++++++++++++--------------- M gui/qt/password_dialog.py | 4 ++-- 2 files changed, 26 insertions(+), 23 deletions(-) --- DIR diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py t@@ -24,6 +24,15 @@ class InstallWizard(QDialog): self.setWindowTitle('Electrum') self.connect(self, QtCore.SIGNAL('accept'), self.accept) + self.stack = QStackedLayout() + self.setLayout(self.stack) + + + def set_layout(self, layout): + w = QWidget() + w.setLayout(layout) + self.stack.setCurrentIndex(self.stack.addWidget(w)) + def restore_or_create(self): t@@ -51,9 +60,10 @@ class InstallWizard(QDialog): grid.addWidget(b2,2,0) grid.addWidget(b3,3,0) - vbox = QVBoxLayout(self) - vbox.addLayout(grid) + vbox = QVBoxLayout() + self.set_layout(vbox) + vbox.addLayout(grid) vbox.addStretch(1) vbox.addLayout(ok_cancel_buttons(self, _('Next'))) t@@ -84,9 +94,7 @@ class InstallWizard(QDialog): def seed_dialog(self, is_restore=True): - if self.layout(): QWidget().setLayout(self.layout()) - - vbox = QVBoxLayout(self) + vbox = QVBoxLayout() if is_restore: msg = _("Please enter your wallet seed.") + "\n" else: t@@ -111,10 +119,10 @@ class InstallWizard(QDialog): vbox.addLayout(grid) - vbox.addStretch(1) vbox.addLayout(ok_cancel_buttons(self, _('Next'))) + self.set_layout(vbox) if not self.exec_(): return t@@ -133,10 +141,10 @@ class InstallWizard(QDialog): task() self.emit(QtCore.SIGNAL('accept')) - if self.layout(): QWidget().setLayout(self.layout()) - vbox = QVBoxLayout(self) + vbox = QVBoxLayout() self.waiting_label = QLabel(msg) vbox.addWidget(self.waiting_label) + self.set_layout(vbox) t = threading.Thread(target = target) t.start() self.exec_() t@@ -145,10 +153,7 @@ class InstallWizard(QDialog): def mpk_dialog(self): - if self.layout(): QWidget().setLayout(self.layout()) - - vbox = QVBoxLayout(self) - + vbox = QVBoxLayout() vbox.addWidget(QLabel(_("Please enter your master public key."))) grid = QGridLayout() t@@ -171,6 +176,7 @@ class InstallWizard(QDialog): vbox.addStretch(1) vbox.addLayout(ok_cancel_buttons(self, _('Next'))) + self.set_layout(vbox) if not self.exec_(): return None, None mpk = str(mpk_e.toPlainText()).strip() t@@ -180,8 +186,6 @@ class InstallWizard(QDialog): def network_dialog(self): - if self.layout(): QWidget().setLayout(self.layout()) - grid = QGridLayout() grid.setSpacing(5) t@@ -206,12 +210,13 @@ class InstallWizard(QDialog): grid.addWidget(b2,2,0) #grid.addWidget(b3,3,0) - vbox = QVBoxLayout(self) + vbox = QVBoxLayout() vbox.addLayout(grid) vbox.addStretch(1) vbox.addLayout(ok_cancel_buttons(self, _('Next'))) + self.set_layout(vbox) if not self.exec_(): return t@@ -227,7 +232,7 @@ class InstallWizard(QDialog): self.config.set_key('auto_cycle', False, True) return - + def show_seed(self, wallet): from seed_dialog import make_seed_dialog t@@ -235,9 +240,7 @@ class InstallWizard(QDialog): vbox = make_seed_dialog(wallet.get_mnemonic(None), wallet.imported_keys) vbox.addLayout(ok_cancel_buttons(self, _("Next"))) - if self.layout(): QWidget().setLayout(self.layout()) - self.setLayout(vbox) - + self.set_layout(vbox) if not self.exec_(): exit() t@@ -246,8 +249,8 @@ class InstallWizard(QDialog): msg = _("Please choose a password to encrypt your wallet keys.")+'\n'\ +_("Leave these fields empty if you want to disable encryption.") from password_dialog import make_password_dialog, run_password_dialog - if self.layout(): QWidget().setLayout(self.layout()) - make_password_dialog(self, wallet, msg) + self.set_layout( make_password_dialog(self, wallet, msg) ) + run_password_dialog(self, wallet, self) DIR diff --git a/gui/qt/password_dialog.py b/gui/qt/password_dialog.py t@@ -68,7 +68,7 @@ def make_password_dialog(self, wallet, msg): vbox.addStretch(1) vbox.addLayout(ok_cancel_buttons(self)) - self.setLayout(vbox) + return vbox def run_password_dialog(self, wallet, parent): t@@ -119,7 +119,7 @@ class PasswordDialog(QDialog): msg = (_('Your wallet is encrypted. Use this dialog to change your password.') + ' '\ +_('To disable wallet encryption, enter an empty new password.')) \ if wallet.use_encryption else _('Your wallet keys are not encrypted') - make_password_dialog(self, wallet, msg) + self.setLayout(make_password_dialog(self, wallet, msg)) def run(self):