Browse Source

kivy: move amount dialog

283
ThomasV 9 years ago
parent
commit
5e5f3202b1
  1. 23
      gui/kivy/main_window.py
  2. 31
      gui/kivy/uix/dialogs/amount_dialog.py
  3. 1774
      gui/kivy/uix/ui_screens/mainscreen.kv

23
gui/kivy/main_window.py

@ -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
def cb():
o = popup.ids.a.btc_text
screen.amount = o
else:
amount = None
popup.on_dismiss = cb
def cb(amount):
screen.amount = amount
popup = AmountDialog(show_max, amount, cb)
popup.open()
def protected(self, f, args):

31
gui/kivy/uix/ui_screens/amount.kv → gui/kivy/uix/dialogs/amount_dialog.py

@ -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

1774
gui/kivy/uix/ui_screens/mainscreen.kv

File diff suppressed because it is too large
Loading…
Cancel
Save