kivy: improve amount dialog
This commit is contained in:
parent
274dc256b5
commit
6e9c58783e
@ -221,20 +221,11 @@
|
||||
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
||||
|
||||
|
||||
#<ElectrumScreen>
|
||||
# ScrollView:
|
||||
# do_scroll_x: False
|
||||
# do_scroll_y: False if root.fullscreen else (content.height > root.height - dp(16))
|
||||
# AnchorLayout:
|
||||
# size_hint_y: None
|
||||
# height: root.height if root.fullscreen else max(root.height, content.height)
|
||||
# GridLayout:
|
||||
# id: content
|
||||
# cols: 1
|
||||
# spacing: '8dp'
|
||||
# padding: '8dp'
|
||||
# size_hint: (1, 1) if root.fullscreen else (.8, None)
|
||||
# height: self.height if root.fullscreen else self.minimum_height
|
||||
<KButton@Button>:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
on_release: self.label.amount = app.update_amount(self.label.amount, self.text)
|
||||
|
||||
|
||||
<TabbedPanelStrip>:
|
||||
on_parent:
|
||||
|
||||
@ -439,6 +439,17 @@ class ElectrumWindow(App):
|
||||
status_card.quote_text = quote_text.strip()
|
||||
status_card.uncomfirmed = unconfirmed.strip()
|
||||
|
||||
|
||||
def update_amount(self, amount, c):
|
||||
if c == '<':
|
||||
return amount[:-1]
|
||||
try:
|
||||
s = amount + c
|
||||
amount = s if Decimal(s)!=0 else ''
|
||||
except:
|
||||
pass
|
||||
return amount
|
||||
|
||||
def format_amount(self, x, is_diff=False, whitespaces=False):
|
||||
from electrum.util import format_satoshis
|
||||
return format_satoshis(x, is_diff, self.num_zeros,
|
||||
@ -712,9 +723,9 @@ class ElectrumWindow(App):
|
||||
if label.text != label.default_text:
|
||||
a, u = label.text.split()
|
||||
assert u == self.base_unit
|
||||
popup.ids.amount_label.value = a
|
||||
popup.ids.a.amount = a
|
||||
def cb():
|
||||
o = popup.ids.amount_label.text
|
||||
o = popup.ids.a.text
|
||||
label.text = o if o else label.default_text
|
||||
if callback:
|
||||
callback()
|
||||
|
||||
@ -1,79 +1,93 @@
|
||||
<KButton@Button>:
|
||||
size_hint: 1, None
|
||||
height: '38dp'
|
||||
#:import Decimal decimal.Decimal
|
||||
|
||||
|
||||
Popup:
|
||||
id: popup
|
||||
title: _('Amount')
|
||||
|
||||
BoxLayout:
|
||||
|
||||
orientation: 'vertical'
|
||||
|
||||
halign: 'center'
|
||||
AnchorLayout:
|
||||
anchor_x: 'center'
|
||||
|
||||
BoxLayout:
|
||||
Label:
|
||||
id: amount_label
|
||||
text: ''
|
||||
value: ''
|
||||
on_value:
|
||||
self.text = self.value + ' ' + app.base_unit
|
||||
orientation: 'vertical'
|
||||
size_hint: 0.8, 1
|
||||
|
||||
BoxLayout:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
id: 'spendable'
|
||||
Label:
|
||||
text: _('Spendable:')
|
||||
size_hint_x: 1
|
||||
Button:
|
||||
size_hint_x: 1
|
||||
height: '48dp'
|
||||
text: ''
|
||||
on_release: a.value = "max"
|
||||
|
||||
BoxLayout:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
Label:
|
||||
id: a
|
||||
amount: ''
|
||||
text: self.amount + ' ' + app.base_unit if self.amount else ''
|
||||
Widget:
|
||||
size_hint_x: 1
|
||||
|
||||
Widget:
|
||||
size_hint_x: 1
|
||||
size_hint: 1, 1
|
||||
|
||||
GridLayout:
|
||||
cols: 3
|
||||
size_hint: 0.5, 1
|
||||
KButton:
|
||||
text: '1'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '2'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '3'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '4'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '5'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '6'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '7'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '8'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '9'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '.'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '0'
|
||||
on_release: amount_label.value += self.text
|
||||
KButton:
|
||||
text: '<'
|
||||
on_release: amount_label.value = amount_label.value[:-1]
|
||||
GridLayout:
|
||||
size_hint: 1, None
|
||||
height: '300dp'
|
||||
cols: 3
|
||||
KButton:
|
||||
text: '1'
|
||||
label: a
|
||||
KButton:
|
||||
text: '2'
|
||||
label: a
|
||||
KButton:
|
||||
text: '3'
|
||||
label: a
|
||||
KButton:
|
||||
text: '4'
|
||||
label: a
|
||||
KButton:
|
||||
text: '5'
|
||||
label: a
|
||||
KButton:
|
||||
text: '6'
|
||||
label: a
|
||||
KButton:
|
||||
text: '7'
|
||||
label: a
|
||||
KButton:
|
||||
text: '8'
|
||||
label: a
|
||||
KButton:
|
||||
text: '9'
|
||||
label: a
|
||||
KButton:
|
||||
text: '.'
|
||||
label: a
|
||||
KButton:
|
||||
text: '0'
|
||||
label: a
|
||||
KButton:
|
||||
text: '<'
|
||||
label: a
|
||||
|
||||
BoxLayout:
|
||||
size_hint: 0.5, None
|
||||
Button:
|
||||
size_hint: 0.5, None
|
||||
BoxLayout:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
text: _('Max')
|
||||
on_release: popup.dismiss()
|
||||
Button:
|
||||
size_hint: 0.5, None
|
||||
height: '48dp'
|
||||
text: _('OK')
|
||||
on_release: popup.dismiss()
|
||||
|
||||
Widget:
|
||||
size_hint: 1, None
|
||||
Widget:
|
||||
size_hint: 0.7, None
|
||||
height: '48dp'
|
||||
Button:
|
||||
size_hint: 0.3, None
|
||||
height: '48dp'
|
||||
text: _('OK')
|
||||
on_release: popup.dismiss()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user