kivy: choice_dialog and load_wallet_by_name
This commit is contained in:
parent
9d3162b1a1
commit
30ace570d3
@ -310,17 +310,21 @@ class ElectrumWindow(App):
|
|||||||
win.bind(keyboard_height=self.on_keyboard_height)
|
win.bind(keyboard_height=self.on_keyboard_height)
|
||||||
|
|
||||||
self.on_size(win, win.size)
|
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
|
config = self.electrum_config
|
||||||
storage = WalletStorage(config.get_wallet_path())
|
storage = WalletStorage(wallet_path)
|
||||||
|
|
||||||
Logger.info('Electrum: Check for existing wallet')
|
Logger.info('Electrum: Check for existing wallet')
|
||||||
|
|
||||||
if storage.file_exists:
|
if storage.file_exists:
|
||||||
wallet = Wallet(storage)
|
wallet = Wallet(storage)
|
||||||
action = wallet.get_action()
|
action = wallet.get_action()
|
||||||
else:
|
else:
|
||||||
action = 'new'
|
action = 'new'
|
||||||
|
|
||||||
if action is not None:
|
if action is not None:
|
||||||
# start installation wizard
|
# start installation wizard
|
||||||
Logger.debug('Electrum: Wallet not found. Launching install wizard')
|
Logger.debug('Electrum: Wallet not found. Launching install wizard')
|
||||||
@ -330,10 +334,25 @@ class ElectrumWindow(App):
|
|||||||
else:
|
else:
|
||||||
wallet.start_threads(self.network)
|
wallet.start_threads(self.network)
|
||||||
self.on_wizard_complete(None, wallet)
|
self.on_wizard_complete(None, wallet)
|
||||||
|
|
||||||
self.on_resume()
|
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):
|
def on_stop(self):
|
||||||
|
self.stop_wallet()
|
||||||
|
|
||||||
|
def stop_wallet(self):
|
||||||
if self.wallet:
|
if self.wallet:
|
||||||
self.wallet.stop_threads()
|
self.wallet.stop_threads()
|
||||||
|
|
||||||
@ -438,7 +457,7 @@ class ElectrumWindow(App):
|
|||||||
interests = ['updated', 'status', 'new_transaction']
|
interests = ['updated', 'status', 'new_transaction']
|
||||||
self.network.register_callback(self.on_network, interests)
|
self.network.register_callback(self.on_network, interests)
|
||||||
|
|
||||||
self.wallet = None
|
#self.wallet = None
|
||||||
self.tabs = self.root.ids['tabs']
|
self.tabs = self.root.ids['tabs']
|
||||||
|
|
||||||
def on_network(self, event, *args):
|
def on_network(self, event, *args):
|
||||||
|
|||||||
62
gui/kivy/uix/dialogs/choice_dialog.py
Normal file
62
gui/kivy/uix/dialogs/choice_dialog.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
from kivy.app import App
|
||||||
|
from kivy.factory import Factory
|
||||||
|
from kivy.properties import ObjectProperty
|
||||||
|
from kivy.lang import Builder
|
||||||
|
from kivy.uix.checkbox import CheckBox
|
||||||
|
from kivy.uix.label import Label
|
||||||
|
|
||||||
|
Builder.load_string('''
|
||||||
|
<ChoiceDialog@Popup>
|
||||||
|
id: popup
|
||||||
|
title: ''
|
||||||
|
size_hint: 0.8, 0.8
|
||||||
|
pos_hint: {'top':0.9}
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
Widget:
|
||||||
|
size_hint: 1, 0.2
|
||||||
|
GridLayout:
|
||||||
|
orientation: 'vertical'
|
||||||
|
id: choices
|
||||||
|
cols: 2
|
||||||
|
size_hint: 1, 0.8
|
||||||
|
Widget:
|
||||||
|
size_hint: 1, 0.8
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'horizontal'
|
||||||
|
size_hint: 1, 0.5
|
||||||
|
Button:
|
||||||
|
text: 'Cancel'
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
on_release: popup.dismiss()
|
||||||
|
Button:
|
||||||
|
text: 'OK'
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
on_release:
|
||||||
|
root.callback(popup.value)
|
||||||
|
popup.dismiss()
|
||||||
|
''')
|
||||||
|
|
||||||
|
class ChoiceDialog(Factory.Popup):
|
||||||
|
|
||||||
|
def __init__(self, title, choices, value, callback):
|
||||||
|
Factory.Popup.__init__(self)
|
||||||
|
for k in choices:
|
||||||
|
l = Label(text=k)
|
||||||
|
l.height = '48dp'
|
||||||
|
l.size_hint_y = 1
|
||||||
|
cb = CheckBox(group='choices')
|
||||||
|
cb.value = k
|
||||||
|
cb.size_hint_y = 1
|
||||||
|
def f(cb, x):
|
||||||
|
if x: self.value = cb.value
|
||||||
|
cb.bind(active=f)
|
||||||
|
if k == value:
|
||||||
|
cb.active = True
|
||||||
|
self.ids.choices.add_widget(l)
|
||||||
|
self.ids.choices.add_widget(cb)
|
||||||
|
self.callback = callback
|
||||||
|
self.title = title
|
||||||
|
self.value = value
|
||||||
@ -1,7 +1,6 @@
|
|||||||
Popup:
|
Popup:
|
||||||
id: settings
|
id: settings
|
||||||
title: _('Settings')
|
title: _('Settings')
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
@ -12,19 +11,17 @@ Popup:
|
|||||||
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
self.title = _('PIN Code') + ' (%s)'%('ON' if app.wallet.use_encryption else 'OFF')
|
||||||
CardSeparator
|
CardSeparator
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
title: _('Denomination') + ' (' + app.base_unit + ')'
|
bu: app.base_unit
|
||||||
|
title: _('Denomination') + ' (' + self.bu + ')'
|
||||||
description: _("Base unit for Bitcoin amounts.")
|
description: _("Base unit for Bitcoin amounts.")
|
||||||
on_release:
|
on_release:
|
||||||
app._rotate_bu()
|
app.unit_dialog(self)
|
||||||
self.title = _('Denomination') + ' (' + app.base_unit + ')'
|
|
||||||
CardSeparator
|
CardSeparator
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
title: _('OpenAlias')
|
title: _('OpenAlias')
|
||||||
description: "Email-like address."
|
description: "Email-like address."
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
|
|||||||
@ -5,31 +5,41 @@ Popup:
|
|||||||
id: popup
|
id: popup
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
GridLayout:
|
Label:
|
||||||
|
id: text_input
|
||||||
|
height: '32dp'
|
||||||
|
size_hint_y: None
|
||||||
|
text: os.path.basename(app.wallet.storage.path)
|
||||||
|
Widget
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
cols: 2
|
|
||||||
Label:
|
|
||||||
height: '32dp'
|
|
||||||
size_hint_y: None
|
|
||||||
text: _('Wallet file') + ':'
|
|
||||||
TextInput:
|
|
||||||
id: text_input
|
|
||||||
height: '32dp'
|
|
||||||
size_hint_y: None
|
|
||||||
text: os.path.basename(app.wallet.storage.path)
|
|
||||||
|
|
||||||
FileChooserIconView:
|
FileChooserListView:
|
||||||
id: wallet_selector
|
id: wallet_selector
|
||||||
path: os.path.dirname(app.wallet.storage.path)
|
path: os.path.dirname(app.wallet.storage.path)
|
||||||
on_selection: text_input.text = os.path.basename(self.selection[0]) if self.selection else ''
|
on_selection:
|
||||||
|
text_input.text = os.path.basename(self.selection[0]) if self.selection else ''
|
||||||
size_hint: 1, 1
|
size_hint: 1, 1
|
||||||
|
|
||||||
BoxLayout:
|
GridLayout:
|
||||||
Widget:
|
cols: 3
|
||||||
size_hint: 0.5, None
|
size_hint_y: None
|
||||||
Button:
|
Button:
|
||||||
size_hint: 0.5, None
|
size_hint: 0.5, None
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
text: _('OK')
|
text: _('Create')
|
||||||
|
on_release:
|
||||||
|
popup.dismiss()
|
||||||
|
app.create_wallet_dialog()
|
||||||
|
Button:
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
text: _('Open')
|
||||||
|
on_release:
|
||||||
|
popup.dismiss()
|
||||||
|
app.open_wallet(text_input.text)
|
||||||
|
Button:
|
||||||
|
size_hint: 0.5, None
|
||||||
|
height: '48dp'
|
||||||
|
text: _('Cancel')
|
||||||
on_release:
|
on_release:
|
||||||
popup.dismiss()
|
popup.dismiss()
|
||||||
|
|||||||
@ -761,6 +761,7 @@ class Transaction:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
def sign(self, keypairs):
|
def sign(self, keypairs):
|
||||||
|
print "sign"
|
||||||
for i, txin in enumerate(self.inputs):
|
for i, txin in enumerate(self.inputs):
|
||||||
num = txin['num_sig']
|
num = txin['num_sig']
|
||||||
for x_pubkey in txin['x_pubkeys']:
|
for x_pubkey in txin['x_pubkeys']:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user