kivy: label dialogs
This commit is contained in:
parent
98d4384641
commit
8977493a62
|
@ -208,12 +208,12 @@
|
|||
values: [] #app.wallet.addresses() if app.wallet else []
|
||||
text: _("Select Your address")
|
||||
|
||||
<AmountButton@Button>:
|
||||
<BlueButton@Button>:
|
||||
background_color: .238, .585, .878, 0
|
||||
halign: 'left'
|
||||
text_size: (self.width-10, None)
|
||||
size_hint: 0.5, None
|
||||
default_text: 'Amount'
|
||||
default_text: ''
|
||||
text: self.default_text
|
||||
padding: '5dp', '5db'
|
||||
height: '40dp'
|
||||
|
|
|
@ -33,6 +33,7 @@ Factory.register('InstallWizard',
|
|||
Factory.register('InfoBubble', module='electrum_gui.kivy.uix.dialogs')
|
||||
Factory.register('ELTextInput', module='electrum_gui.kivy.uix.screens')
|
||||
|
||||
|
||||
#from kivy.core.window import Window
|
||||
#Window.softinput_mode = 'below_target'
|
||||
|
||||
|
@ -719,12 +720,18 @@ class ElectrumWindow(App):
|
|||
popup.tx_hash = obj.tx_hash
|
||||
popup.open()
|
||||
|
||||
def tx_label_dialog(self, obj):
|
||||
pass
|
||||
|
||||
def address_dialog(self, screen):
|
||||
pass
|
||||
|
||||
def description_dialog(self, screen):
|
||||
from uix.dialogs.label_dialog import LabelDialog
|
||||
text = screen.message
|
||||
def callback(text):
|
||||
screen.message = text
|
||||
d = LabelDialog(_('Enter description'), text, callback)
|
||||
d.open()
|
||||
|
||||
|
||||
def amount_dialog(self, screen, show_max):
|
||||
popup = Builder.load_file('gui/kivy/uix/ui_screens/amount.kv')
|
||||
but_max = popup.ids.but_max
|
||||
|
|
|
@ -39,5 +39,8 @@ class ContextMenu(Bubble):
|
|||
for k, v in action_list:
|
||||
l = MenuItem()
|
||||
l.text = k
|
||||
l.on_release = lambda f=v: f(obj)
|
||||
def func(f=v):
|
||||
f(obj)
|
||||
if self.parent: self.parent.hide_menu()
|
||||
l.on_release = func
|
||||
self.ids.buttons.add_widget(l)
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
from kivy.app import App
|
||||
from kivy.factory import Factory
|
||||
from kivy.properties import ObjectProperty
|
||||
from kivy.lang import Builder
|
||||
|
||||
Builder.load_string('''
|
||||
<LabelDialog@Popup>
|
||||
id: popup
|
||||
title: ''
|
||||
size_hint: 0.8, 0.3
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
Widget:
|
||||
size_hint: 1, 0.2
|
||||
TextInput:
|
||||
id:input
|
||||
padding: '5dp'
|
||||
size_hint: 1, None
|
||||
height: '27dp'
|
||||
pos_hint: {'center_y':.5}
|
||||
text:''
|
||||
multiline: False
|
||||
background_normal: 'atlas://gui/kivy/theming/light/tab_btn'
|
||||
background_active: 'atlas://gui/kivy/theming/light/textinput_active'
|
||||
hint_text_color: self.foreground_color
|
||||
foreground_color: 1, 1, 1, 1
|
||||
font_size: '16dp'
|
||||
focus: True
|
||||
Widget:
|
||||
size_hint: 1, 0.2
|
||||
BoxLayout:
|
||||
orientation: 'horizontal'
|
||||
size_hint: 1, 0.5
|
||||
Button:
|
||||
text: 'Cancel'
|
||||
size_hint: 0.5, None
|
||||
height: '48dp'
|
||||
on_release: popup.dismiss()
|
||||
Button:
|
||||
text: 'OK'
|
||||
size_hint: 0.5, None
|
||||
height: '48dp'
|
||||
on_release:
|
||||
root.callback(input.text)
|
||||
popup.dismiss()
|
||||
''')
|
||||
|
||||
class LabelDialog(Factory.Popup):
|
||||
|
||||
def __init__(self, title, text, callback):
|
||||
Factory.Popup.__init__(self)
|
||||
self.ids.input.text = text
|
||||
self.callback = callback
|
||||
self.title = title
|
|
@ -95,7 +95,17 @@ class HistoryScreen(CScreen):
|
|||
def __init__(self, **kwargs):
|
||||
self.ra_dialog = None
|
||||
super(HistoryScreen, self).__init__(**kwargs)
|
||||
self.menu_actions = [ (_('Label'), self.app.tx_label_dialog), (_('Details'), self.app.tx_details_dialog)]
|
||||
self.menu_actions = [ (_('Label'), self.label_dialog), (_('Details'), self.app.tx_details_dialog)]
|
||||
|
||||
def label_dialog(self, obj):
|
||||
from dialogs.label_dialog import LabelDialog
|
||||
key = obj.tx_hash
|
||||
text = self.app.wallet.get_label(key)[0]
|
||||
def callback(text):
|
||||
self.app.wallet.set_label(key, text)
|
||||
self.update()
|
||||
d = LabelDialog(_('Enter Transaction Label'), text, callback)
|
||||
d.open()
|
||||
|
||||
def get_history_rate(self, btc_balance, timestamp):
|
||||
date = timestamp_to_datetime(timestamp)
|
||||
|
|
|
@ -56,8 +56,9 @@ ReceiveScreen:
|
|||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
pos_hint: {'center_y': .5}
|
||||
AmountButton:
|
||||
BlueButton:
|
||||
id: amount_label
|
||||
default_text: 'Amount'
|
||||
text: s.amount if s.amount else 'Amount'
|
||||
on_release: app.amount_dialog(s, False)
|
||||
CardSeparator:
|
||||
|
@ -74,11 +75,10 @@ ReceiveScreen:
|
|||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
pos_hint: {'center_y': .5}
|
||||
TextInputBlue:
|
||||
id: message_input
|
||||
hint_text: 'Description'
|
||||
text: s.message
|
||||
on_text_validate: s.message = self.text
|
||||
BlueButton:
|
||||
id: description
|
||||
text: s.message if s.message else _('Description')
|
||||
on_release: app.description_dialog(s)
|
||||
BoxLayout:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
|
|
|
@ -32,7 +32,7 @@ SendScreen:
|
|||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
pos_hint: {'center_y': .5}
|
||||
AmountButton:
|
||||
BlueButton:
|
||||
id: payto_e
|
||||
text: s.address if s.address else _('Recipient')
|
||||
on_release: app.address_dialog(s)
|
||||
|
@ -47,8 +47,9 @@ SendScreen:
|
|||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
pos_hint: {'center_y': .5}
|
||||
AmountButton:
|
||||
BlueButton:
|
||||
id: amount_e
|
||||
default_text: _('Amount')
|
||||
text: s.amount if s.amount else _('Amount')
|
||||
on_release: app.amount_dialog(s, True)
|
||||
|
||||
|
@ -66,11 +67,10 @@ SendScreen:
|
|||
size_hint: None, None
|
||||
size: '22dp', '22dp'
|
||||
pos_hint: {'center_y': .5}
|
||||
TextInputBlue:
|
||||
id: message_e
|
||||
hint_text: _('Description')
|
||||
text: s.message
|
||||
on_text_validate: s.message = self.text
|
||||
BlueButton:
|
||||
id: description
|
||||
text: s.message if s.message else _('Description')
|
||||
on_release: app.description_dialog(s)
|
||||
BoxLayout:
|
||||
size_hint: 1, None
|
||||
height: '48dp'
|
||||
|
|
Loading…
Reference in New Issue