tkiv: add option to delete a wallet - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit e49fc05c49201496aa721eee9dd0beb7d940084d (DIR) parent a79b4e6de64332e4bbd10d87f2b89fd6d0b11d96 (HTM) Author: ThomasV <thomasv@electrum.org> Date: Sat, 4 Jun 2016 22:40:01 +0200 kiv: add option to delete a wallet Diffstat: M gui/kivy/uix/dialogs/wallets.py | 38 +++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) --- (DIR) diff --git a/gui/kivy/uix/dialogs/wallets.py b/gui/kivy/uix/dialogs/wallets.py t@@ -28,31 +28,51 @@ Builder.load_string(''' Widget size_hint_y: 0.1 GridLayout: - cols: 2 + cols: 3 size_hint_y: 0.1 Button: + id: open_button size_hint: 0.1, None height: '48dp' - text: _('Cancel') + text: _('New') on_release: popup.dismiss() + root.new_wallet(app, wallet_selector.path) Button: id: open_button size_hint: 0.1, None height: '48dp' - text: _('Open') if wallet_selector.selection else _('New Wallet') + text: _('Open') + disabled: not wallet_selector.selection on_release: popup.dismiss() - root.new_wallet(app, wallet_selector.path) + root.open_wallet(app) + Button: + id: open_button + size_hint: 0.1, None + height: '48dp' + text: _('Delete') + disabled: not wallet_selector.selection + on_release: + popup.dismiss() + root.delete_wallet(app) ''') class WalletDialog(Factory.Popup): + def new_wallet(self, app, dirname): def cb(text): if text: app.load_wallet_by_name(os.path.join(dirname, text)) - if self.ids.wallet_selector.selection: - app.load_wallet_by_name(self.ids.wallet_selector.selection[0]) - else: - d = LabelDialog(_('Enter wallet name'), '', cb) - d.open() + d = LabelDialog(_('Enter wallet name'), '', cb) + d.open() + + def open_wallet(self, app): + app.load_wallet_by_name(self.ids.wallet_selector.selection[0]) + + def delete_wallet(self, app): + from question import Question + name = self.ids.wallet_selector.selection[0] + f = lambda: os.unlink(name) + d = Question(_('Delete wallet?') + '\n' + os.path.basename(name), f) + d.open()