1
0

kivy: choice_dialog and load_wallet_by_name

This commit is contained in:
ThomasV
2015-12-16 08:57:47 +01:00
parent 9d3162b1a1
commit 30ace570d3
5 changed files with 118 additions and 29 deletions

View File

@@ -310,17 +310,21 @@ class ElectrumWindow(App):
win.bind(keyboard_height=self.on_keyboard_height)
self.on_size(win, win.size)
self.load_wallet_by_name(self.electrum_config.get_wallet_path())
def load_wallet_by_name(self, wallet_path):
if not wallet_path:
return
self.stop_wallet()
config = self.electrum_config
storage = WalletStorage(config.get_wallet_path())
storage = WalletStorage(wallet_path)
Logger.info('Electrum: Check for existing wallet')
if storage.file_exists:
wallet = Wallet(storage)
action = wallet.get_action()
else:
action = 'new'
if action is not None:
# start installation wizard
Logger.debug('Electrum: Wallet not found. Launching install wizard')
@@ -330,10 +334,25 @@ class ElectrumWindow(App):
else:
wallet.start_threads(self.network)
self.on_wizard_complete(None, wallet)
self.on_resume()
def create_wallet_dialog(self):
from uix.dialogs.label_dialog import LabelDialog
d = LabelDialog(_('Enter wallet name'), '', self.load_wallet_by_name)
d.open()
def unit_dialog(self, item):
from uix.dialogs.choice_dialog import ChoiceDialog
def cb(text):
self._set_bu(text)
item.bu = self.base_unit
d = ChoiceDialog(_('Denomination'), sorted(base_units.keys()), self.base_unit, cb)
d.open()
def on_stop(self):
self.stop_wallet()
def stop_wallet(self):
if self.wallet:
self.wallet.stop_threads()
@@ -438,7 +457,7 @@ class ElectrumWindow(App):
interests = ['updated', 'status', 'new_transaction']
self.network.register_callback(self.on_network, interests)
self.wallet = None
#self.wallet = None
self.tabs = self.root.ids['tabs']
def on_network(self, event, *args):