kivy: use Clock.schedule_once for actions in settings menu
This commit is contained in:
parent
488bdbf4b5
commit
9580cd62f6
|
@ -10,6 +10,8 @@ from electrum.plugins import run_hook
|
||||||
from electrum.bitcoin import RECOMMENDED_FEE
|
from electrum.bitcoin import RECOMMENDED_FEE
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
|
#:import partial functools.partial
|
||||||
|
|
||||||
<SettingsItem@ButtonBehavior+BoxLayout>
|
<SettingsItem@ButtonBehavior+BoxLayout>
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
title: ''
|
title: ''
|
||||||
|
@ -22,6 +24,8 @@ Builder.load_string('''
|
||||||
Rectangle:
|
Rectangle:
|
||||||
size: self.size
|
size: self.size
|
||||||
pos: self.pos
|
pos: self.pos
|
||||||
|
on_release:
|
||||||
|
Clock.schedule_once(self.action)
|
||||||
|
|
||||||
Label:
|
Label:
|
||||||
id: title
|
id: title
|
||||||
|
@ -55,45 +59,37 @@ Builder.load_string('''
|
||||||
lang: settings.get_language_name()
|
lang: settings.get_language_name()
|
||||||
title: _('Language') + ': %s'%self.lang
|
title: _('Language') + ': %s'%self.lang
|
||||||
description: _("Language")
|
description: _("Language")
|
||||||
on_release:
|
action: partial(root.language_dialog, self)
|
||||||
settings.language_dialog(self)
|
|
||||||
height: '48dp'
|
height: '48dp'
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: 'ON' if app.wallet.use_encryption else 'OFF'
|
status: 'ON' if app.wallet.use_encryption else 'OFF'
|
||||||
title: _('PIN code') + ': ' + self.status
|
title: _('PIN code') + ': ' + self.status
|
||||||
description: _("Change your PIN code.")
|
description: _("Change your PIN code.")
|
||||||
on_release:
|
action: partial(root.change_password, self)
|
||||||
app.change_password()
|
|
||||||
self.status = 'ON' if app.wallet.use_encryption else 'OFF'
|
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
bu: app.base_unit
|
bu: app.base_unit
|
||||||
title: _('Denomination') + ': ' + self.bu
|
title: _('Denomination') + ': ' + self.bu
|
||||||
description: _("Base unit for Bitcoin amounts.")
|
description: _("Base unit for Bitcoin amounts.")
|
||||||
on_release:
|
action: partial(root.unit_dialog, self)
|
||||||
settings.unit_dialog(self)
|
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: root.fee_status()
|
status: root.fee_status()
|
||||||
title: _('Fees') + ': ' + self.status
|
title: _('Fees') + ': ' + self.status
|
||||||
description: _("Fees paid to the Bitcoin miners.")
|
description: _("Fees paid to the Bitcoin miners.")
|
||||||
on_release:
|
action: partial(root.fee_dialog, self)
|
||||||
root.fee_dialog(self)
|
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: root.fx_status()
|
status: root.fx_status()
|
||||||
title: _('Fiat Currency') + ': ' + self.status
|
title: _('Fiat Currency') + ': ' + self.status
|
||||||
description: _("Display amounts in fiat currency.")
|
description: _("Display amounts in fiat currency.")
|
||||||
on_release:
|
action: partial(root.fx_dialog, self)
|
||||||
root.fx_dialog(self)
|
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
status: 'ON' if bool(app.plugins.get('labels')) else 'OFF'
|
status: 'ON' if bool(app.plugins.get('labels')) else 'OFF'
|
||||||
title: _('Labels Sync') + ': ' + self.status
|
title: _('Labels Sync') + ': ' + self.status
|
||||||
description: "Synchronize labels."
|
description: "Synchronize labels."
|
||||||
on_release:
|
action: partial(root.plugin_dialog, 'labels', self)
|
||||||
settings.plugin_dialog('labels', self)
|
|
||||||
SettingsItem:
|
SettingsItem:
|
||||||
title: _('OpenAlias')
|
title: _('OpenAlias')
|
||||||
description: "DNS record that stores one of your Bitcoin addresses."
|
description: "DNS record that stores one of your Bitcoin addresses."
|
||||||
on_release:
|
action: partial(root.openalias_dialog, self)
|
||||||
settings.openalias_dialog()
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.1
|
||||||
Widget:
|
Widget:
|
||||||
|
@ -119,7 +115,10 @@ class SettingsDialog(Factory.Popup):
|
||||||
def get_language_name(self):
|
def get_language_name(self):
|
||||||
return languages.get(self.config.get('language', 'en_UK'), '')
|
return languages.get(self.config.get('language', 'en_UK'), '')
|
||||||
|
|
||||||
def language_dialog(self, item):
|
def change_password(self, label, dt):
|
||||||
|
self.app.change_password()
|
||||||
|
|
||||||
|
def language_dialog(self, item, dt):
|
||||||
from choice_dialog import ChoiceDialog
|
from choice_dialog import ChoiceDialog
|
||||||
l = self.config.get('language', 'en_UK')
|
l = self.config.get('language', 'en_UK')
|
||||||
def cb(key):
|
def cb(key):
|
||||||
|
@ -129,7 +128,7 @@ class SettingsDialog(Factory.Popup):
|
||||||
d = ChoiceDialog(_('Language'), languages, l, cb)
|
d = ChoiceDialog(_('Language'), languages, l, cb)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def unit_dialog(self, item):
|
def unit_dialog(self, item, dt):
|
||||||
from choice_dialog import ChoiceDialog
|
from choice_dialog import ChoiceDialog
|
||||||
def cb(text):
|
def cb(text):
|
||||||
self.app._set_bu(text)
|
self.app._set_bu(text)
|
||||||
|
@ -137,14 +136,14 @@ class SettingsDialog(Factory.Popup):
|
||||||
d = ChoiceDialog(_('Denomination'), base_units.keys(), self.app.base_unit, cb)
|
d = ChoiceDialog(_('Denomination'), base_units.keys(), self.app.base_unit, cb)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def openalias_dialog(self):
|
def openalias_dialog(self, label, dt):
|
||||||
from label_dialog import LabelDialog
|
from label_dialog import LabelDialog
|
||||||
def callback(text):
|
def callback(text):
|
||||||
pass
|
label.text = text
|
||||||
d = LabelDialog(_('OpenAlias'), '', callback)
|
d = LabelDialog(_('OpenAlias'), '', callback)
|
||||||
d.open()
|
d.open()
|
||||||
|
|
||||||
def plugin_dialog(self, name, label):
|
def plugin_dialog(self, name, label, dt):
|
||||||
from checkbox_dialog import CheckBoxDialog
|
from checkbox_dialog import CheckBoxDialog
|
||||||
def callback(status):
|
def callback(status):
|
||||||
self.plugins.enable(name) if status else self.plugins.disable(name)
|
self.plugins.enable(name) if status else self.plugins.disable(name)
|
||||||
|
@ -165,7 +164,7 @@ class SettingsDialog(Factory.Popup):
|
||||||
F = self.config.get('fee_per_kb', RECOMMENDED_FEE)
|
F = self.config.get('fee_per_kb', RECOMMENDED_FEE)
|
||||||
return self.app.format_amount(F) + ' ' + self.app.base_unit + '/kB'
|
return self.app.format_amount(F) + ' ' + self.app.base_unit + '/kB'
|
||||||
|
|
||||||
def fee_dialog(self, label):
|
def fee_dialog(self, label, dt):
|
||||||
from fee_dialog import FeeDialog
|
from fee_dialog import FeeDialog
|
||||||
def cb():
|
def cb():
|
||||||
label.status = self.fee_status()
|
label.status = self.fee_status()
|
||||||
|
@ -181,7 +180,7 @@ class SettingsDialog(Factory.Popup):
|
||||||
else:
|
else:
|
||||||
return 'Disabled'
|
return 'Disabled'
|
||||||
|
|
||||||
def fx_dialog(self, label):
|
def fx_dialog(self, label, dt):
|
||||||
from fx_dialog import FxDialog
|
from fx_dialog import FxDialog
|
||||||
def cb():
|
def cb():
|
||||||
label.status = self.fx_status()
|
label.status = self.fx_status()
|
||||||
|
|
Loading…
Reference in New Issue