kivy: move amount dialog

This commit is contained in:
ThomasV 2015-12-14 14:27:39 +01:00
parent c55a253f6d
commit 5e5f3202b1
3 changed files with 31 additions and 1797 deletions

View File

@ -733,26 +733,17 @@ class ElectrumWindow(App):
def amount_dialog(self, screen, show_max):
popup = Builder.load_file('gui/kivy/uix/ui_screens/amount.kv')
but_max = popup.ids.but_max
if not show_max:
but_max.disabled = True
but_max.opacity = 0
else:
but_max.disabled = False
but_max.opacity = 1
from uix.dialogs.amount_dialog import AmountDialog
amount = screen.amount
if amount:
a, u = str(amount).split()
amount, u = str(amount).split()
assert u == self.base_unit
popup.ids.kb.amount = a
else:
amount = None
def cb():
o = popup.ids.a.btc_text
screen.amount = o
popup.on_dismiss = cb
def cb(amount):
screen.amount = amount
popup = AmountDialog(show_max, amount, cb)
popup.open()
def protected(self, f, args):

View File

@ -1,13 +1,15 @@
#:import Decimal decimal.Decimal
from kivy.app import App
from kivy.factory import Factory
from kivy.properties import ObjectProperty
from kivy.lang import Builder
Popup:
Builder.load_string('''
<AmountDialog@Popup>
id: popup
title: _('Amount')
AnchorLayout:
anchor_x: 'center'
BoxLayout:
orientation: 'vertical'
size_hint: 0.8, 1
@ -60,6 +62,8 @@ Popup:
text: '<'
Button:
id: but_max
opacity: 1 if root.show_max else 0
disabled: not root.show_max
size_hint: 1, None
height: '48dp'
text: 'Max'
@ -80,10 +84,8 @@ Popup:
on_release:
kb.amount = ''
kb.fiat_amount = ''
Widget:
size_hint: 1, None
BoxLayout:
size_hint: 1, None
height: '48dp'
@ -94,4 +96,19 @@ Popup:
size_hint: 1, None
height: '48dp'
text: _('OK')
on_release: popup.dismiss()
on_release:
root.callback(a.btc_text)
popup.dismiss()
''')
from kivy.properties import BooleanProperty
class AmountDialog(Factory.Popup):
show_max = BooleanProperty(False)
def __init__(self, show_max, amount, cb):
Factory.Popup.__init__(self)
self.show_max = show_max
self.callback = cb
if amount:
self.ids.kb.amount = amount

File diff suppressed because it is too large Load Diff