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.

58 lines
1.6 KiB

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
import os
from label_dialog import LabelDialog
Builder.load_string('''
#:import os os
<WalletDialog@Popup>:
9 years ago
title: _('Wallets')
id: popup
path: ''
9 years ago
BoxLayout:
orientation: 'vertical'
FileChooserListView:
9 years ago
id: wallet_selector
dirselect: False
filter_dirs: True
filter: '*.*'
9 years ago
path: os.path.dirname(app.wallet.storage.path)
size_hint_y: 0.6
Widget
size_hint_y: 0.1
GridLayout:
cols: 2
size_hint_y: 0.1
Button:
size_hint: 0.1, None
height: '48dp'
text: _('Cancel')
on_release:
popup.dismiss()
9 years ago
Button:
id: open_button
size_hint: 0.1, None
9 years ago
height: '48dp'
text: _('Open') if wallet_selector.selection else _('New Wallet')
9 years ago
on_release:
popup.dismiss()
9 years ago
root.new_wallet(app, wallet_selector.path)
''')
class WalletDialog(Factory.Popup):
9 years ago
def new_wallet(self, app, dirname):
def cb(text):
if text:
9 years ago
app.load_wallet_by_name(os.path.join(dirname, text))
if self.path:
app.load_wallet_by_name(self.path)
else:
d = LabelDialog(_('Enter wallet name'), '', cb)
d.open()