-WIP-electrum-btcp/gui/kivy/uix/dialogs/wallets.py

58 lines
1.6 KiB
Python
Raw Normal View History

2015-12-18 06:03:38 -08:00
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
2015-12-18 06:03:38 -08:00
import os
from label_dialog import LabelDialog
Builder.load_string('''
#:import os os
<WalletDialog@Popup>:
2015-12-02 03:11:28 -08:00
title: _('Wallets')
id: popup
2016-01-18 01:08:21 -08:00
path: ''
2015-10-07 04:48:58 -07:00
BoxLayout:
orientation: 'vertical'
FileChooserListView:
2015-10-07 04:48:58 -07:00
id: wallet_selector
2015-12-20 08:37:07 -08:00
dirselect: False
filter_dirs: True
filter: '*.*'
2015-10-07 04:48:58 -07:00
path: os.path.dirname(app.wallet.storage.path)
2016-01-19 06:57:11 -08:00
size_hint_y: 0.6
2015-12-18 01:53:50 -08:00
Widget
size_hint_y: 0.1
GridLayout:
2015-12-18 01:53:50 -08:00
cols: 2
2016-01-19 06:57:11 -08:00
size_hint_y: 0.1
Button:
2016-01-19 06:57:11 -08:00
size_hint: 0.1, None
height: '48dp'
2015-12-18 01:53:50 -08:00
text: _('Cancel')
on_release:
popup.dismiss()
2015-12-02 03:11:28 -08:00
Button:
2016-01-18 01:08:21 -08:00
id: open_button
2016-01-19 06:57:11 -08:00
size_hint: 0.1, None
2015-12-02 03:11:28 -08:00
height: '48dp'
2016-01-19 06:57:11 -08:00
text: _('Open') if wallet_selector.selection else _('New Wallet')
2015-12-02 03:11:28 -08:00
on_release:
popup.dismiss()
2016-01-18 05:09:48 -08:00
root.new_wallet(app, wallet_selector.path)
2015-12-18 06:03:38 -08:00
''')
class WalletDialog(Factory.Popup):
2016-01-18 05:09:48 -08:00
def new_wallet(self, app, dirname):
2015-12-18 06:03:38 -08:00
def cb(text):
if text:
2016-01-18 05:09:48 -08:00
app.load_wallet_by_name(os.path.join(dirname, text))
2016-01-18 01:08:21 -08:00
if self.path:
app.load_wallet_by_name(self.path)
else:
d = LabelDialog(_('Enter wallet name'), '', cb)
d.open()