electrum-bitcoinprivate/gui/kivy/uix/dialogs/wallets.py

66 lines
1.7 KiB
Python
Raw Normal View History

import os
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
2019-02-28 13:26:15 -08:00
from electrum_zclassic.util import base_units
from ...i18n import _
from .label_dialog import LabelDialog
2015-12-18 06:03:38 -08:00
Builder.load_string('''
#:import os os
<WalletDialog@Popup>:
2015-12-02 03:11:28 -08:00
title: _('Wallets')
id: popup
2016-06-05 06:38:06 -07:00
path: os.path.dirname(app.get_wallet_path())
2015-10-07 04:48:58 -07:00
BoxLayout:
orientation: 'vertical'
2016-03-06 05:49:50 -08:00
padding: '10dp'
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: '*.*'
2016-06-05 06:38:06 -07:00
path: root.path
rootpath: root.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:
2016-06-04 13:40:01 -07:00
cols: 3
2016-01-19 06:57:11 -08:00
size_hint_y: 0.1
Button:
2016-06-04 13:40:01 -07:00
id: open_button
2016-01-19 06:57:11 -08:00
size_hint: 0.1, None
height: '48dp'
2016-06-04 13:40:01 -07:00
text: _('New')
on_release:
popup.dismiss()
2016-06-04 13:40:01 -07:00
root.new_wallet(app, wallet_selector.path)
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-06-04 13:40:01 -07:00
text: _('Open')
disabled: not wallet_selector.selection
2015-12-02 03:11:28 -08:00
on_release:
popup.dismiss()
2016-06-04 13:40:01 -07:00
root.open_wallet(app)
2015-12-18 06:03:38 -08:00
''')
class WalletDialog(Factory.Popup):
2016-06-04 13:40:01 -07:00
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-06-04 13:40:01 -07:00
d = LabelDialog(_('Enter wallet name'), '', cb)
d.open()
def open_wallet(self, app):
app.load_wallet_by_name(self.ids.wallet_selector.selection[0])