You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.2 KiB
77 lines
2.2 KiB
9 years ago
|
from kivy.app import App
|
||
|
from kivy.factory import Factory
|
||
|
from kivy.properties import ObjectProperty
|
||
|
from kivy.lang import Builder
|
||
|
|
||
|
from electrum.i18n import _
|
||
|
from electrum.util import base_units
|
||
9 years ago
|
|
||
9 years ago
|
import os
|
||
|
from label_dialog import LabelDialog
|
||
|
|
||
|
Builder.load_string('''
|
||
|
#:import os os
|
||
|
<WalletDialog@Popup>:
|
||
9 years ago
|
title: _('Wallets')
|
||
|
id: popup
|
||
9 years ago
|
path: app.wallet.storage.path
|
||
|
on_path:
|
||
|
button.text = _('Open') if os.path.exists(popup.path) else _('Create')
|
||
9 years ago
|
BoxLayout:
|
||
|
orientation: 'vertical'
|
||
9 years ago
|
BoxLayout:
|
||
|
height: '48dp'
|
||
9 years ago
|
size_hint_y: None
|
||
9 years ago
|
orientation: 'horizontal'
|
||
|
Label:
|
||
|
text: _('Wallet') + ': '
|
||
|
height: '48dp'
|
||
|
size_hint_y: None
|
||
|
Button:
|
||
|
id: wallet_name
|
||
|
height: '48dp'
|
||
|
size_hint_y: None
|
||
|
text: os.path.basename(app.wallet.storage.path)
|
||
|
on_release:
|
||
9 years ago
|
root.name_dialog()
|
||
9 years ago
|
on_text:
|
||
|
popup.path = os.path.join(wallet_selector.path, self.text)
|
||
9 years ago
|
Widget
|
||
9 years ago
|
size_hint_y: None
|
||
9 years ago
|
FileChooserListView:
|
||
9 years ago
|
id: wallet_selector
|
||
|
path: os.path.dirname(app.wallet.storage.path)
|
||
9 years ago
|
on_selection:
|
||
9 years ago
|
wallet_name.text = os.path.basename(self.selection[0]) if self.selection else ''
|
||
|
size_hint_y: 0.5
|
||
|
Widget
|
||
|
size_hint_y: 0.1
|
||
9 years ago
|
|
||
9 years ago
|
GridLayout:
|
||
9 years ago
|
cols: 2
|
||
9 years ago
|
size_hint_y: None
|
||
|
Button:
|
||
9 years ago
|
size_hint: 0.5, None
|
||
9 years ago
|
height: '48dp'
|
||
9 years ago
|
text: _('Cancel')
|
||
9 years ago
|
on_release:
|
||
|
popup.dismiss()
|
||
9 years ago
|
Button:
|
||
9 years ago
|
id: button
|
||
9 years ago
|
size_hint: 0.5, None
|
||
|
height: '48dp'
|
||
9 years ago
|
text: _('Open') if os.path.exists(popup.path) else _('Create')
|
||
9 years ago
|
on_release:
|
||
|
popup.dismiss()
|
||
9 years ago
|
app.load_wallet_by_name(popup.path)
|
||
9 years ago
|
''')
|
||
|
|
||
|
class WalletDialog(Factory.Popup):
|
||
|
def name_dialog(self):
|
||
|
def cb(text):
|
||
|
if text:
|
||
|
self.ids.wallet_name.text = text
|
||
|
d = LabelDialog(_('Enter wallet name'), '', cb)
|
||
|
d.open()
|
||
|
|