kivy: add OutputList class
This commit is contained in:
parent
c2d3968ebe
commit
74c9a05757
|
@ -79,6 +79,20 @@
|
|||
# Dialogs
|
||||
#########################
|
||||
|
||||
<OutputList>
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
cols: 2
|
||||
spacing: '10dp'
|
||||
padding: '10dp'
|
||||
canvas.before:
|
||||
Color:
|
||||
rgb: .3, .3, .3
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
|
||||
|
||||
<InfoBubble>
|
||||
size_hint: None, None
|
||||
width: '270dp' if root.fs else min(self.width, dp(270))
|
||||
|
|
|
@ -31,7 +31,8 @@ from kivy.lang import Builder
|
|||
Factory.register('InstallWizard',
|
||||
module='electrum_gui.kivy.uix.dialogs.installwizard')
|
||||
Factory.register('InfoBubble', module='electrum_gui.kivy.uix.dialogs')
|
||||
Factory.register('ELTextInput', module='electrum_gui.kivy.uix.screens')
|
||||
#Factory.register('ELTextInput', module='electrum_gui.kivy.uix.screens')
|
||||
Factory.register('OutputList', module='electrum_gui.kivy.uix.dialogs')
|
||||
|
||||
|
||||
#from kivy.core.window import Window
|
||||
|
@ -614,7 +615,7 @@ class ElectrumWindow(App):
|
|||
exit=False, duration=0, modal=False):
|
||||
''' Show a Info Message Bubble.
|
||||
'''
|
||||
self.show_error(error, icon='atlas://gui/kivy/theming/light/error',
|
||||
self.show_error(error, icon='atlas://gui/kivy/theming/light/important',
|
||||
duration=duration, modal=modal, exit=exit, pos=pos,
|
||||
arrow_pos=arrow_pos)
|
||||
|
||||
|
|
|
@ -189,3 +189,26 @@ class InfoBubble(Factory.Bubble):
|
|||
anim.bind(on_complete=on_stop)
|
||||
anim.cancel_all(self)
|
||||
anim.start(self)
|
||||
|
||||
|
||||
class OutputList(Factory.GridLayout):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(Factory.GridLayout, self).__init__(**kwargs)
|
||||
self.app = App.get_running_app()
|
||||
|
||||
def add_output(self, address, amount):
|
||||
t = Factory.CardLabel(text = '[ref=%s]%s[/ref]'%(address,address), font_size = '6pt')
|
||||
t.shorten = True
|
||||
t.size_hint_x = 0.65
|
||||
t.on_ref_press = self.do_copy_address
|
||||
self.add_widget(t)
|
||||
t = Factory.CardLabel(text = self.app.format_amount_and_units(amount), font_size='6pt')
|
||||
t.size_hint_x = 0.35
|
||||
t.halign = 'right'
|
||||
self.add_widget(t)
|
||||
|
||||
def do_copy_address(self, text):
|
||||
self.app._clipboard.copy(text)
|
||||
self.app.show_info(_('Address copied to clipboard') + ' ' + text)
|
||||
|
||||
|
|
|
@ -52,23 +52,10 @@ Builder.load_string('''
|
|||
text: _('Transaction fee') if root.fee_str else ''
|
||||
TopLabel:
|
||||
text: root.fee_str
|
||||
|
||||
TopLabel:
|
||||
text: _('Outputs') + ':'
|
||||
|
||||
GridLayout:
|
||||
OutputList:
|
||||
id: outputs
|
||||
size_hint: 1, None
|
||||
height: self.minimum_height
|
||||
cols: 2
|
||||
spacing: '10dp'
|
||||
padding: '10dp'
|
||||
canvas.before:
|
||||
Color:
|
||||
rgb: .3, .3, .3
|
||||
Rectangle:
|
||||
size: self.size
|
||||
pos: self.pos
|
||||
TopLabel:
|
||||
text: _('Transaction ID') + ':' if root.tx_hash else ''
|
||||
TopLabel:
|
||||
|
@ -111,6 +98,7 @@ Builder.load_string('''
|
|||
on_release: popup.dismiss()
|
||||
''')
|
||||
|
||||
|
||||
class TxDialog(Factory.Popup):
|
||||
|
||||
def __init__(self, app, tx):
|
||||
|
@ -155,20 +143,9 @@ class TxDialog(Factory.Popup):
|
|||
self.fee_str = ''
|
||||
self.can_sign = self.wallet.can_sign(self.tx)
|
||||
|
||||
self.ids.outputs.clear_widgets()
|
||||
for (type, address, amount) in self.tx.outputs():
|
||||
t = Factory.CardLabel(text = '[ref=%s]%s[/ref]'%(address,address), font_size = '6pt')
|
||||
t.shorten = True
|
||||
t.size_hint_x = 0.65
|
||||
t.on_ref_press = self.do_copy_address
|
||||
self.ids.outputs.add_widget(t)
|
||||
t = Factory.CardLabel(text = self.app.format_amount_and_units(amount), font_size='6pt')
|
||||
t.size_hint_x = 0.35
|
||||
t.halign = 'right'
|
||||
self.ids.outputs.add_widget(t)
|
||||
|
||||
def do_copy_address(self, text):
|
||||
self.app._clipboard.copy(text)
|
||||
self.app.show_info(_('Address copied to clipboard'))
|
||||
self.ids.outputs.add_output(address, amount)
|
||||
|
||||
def do_sign(self):
|
||||
self.app.protected(_("Enter your PIN code in order to sign this transaction"), self._do_sign, ())
|
||||
|
|
|
@ -480,6 +480,7 @@ class Transaction:
|
|||
else:
|
||||
raise BaseException("cannot initialize transaction", raw)
|
||||
self._inputs = None
|
||||
self._outputs = None
|
||||
|
||||
def update(self, raw):
|
||||
self.raw = raw
|
||||
|
|
Loading…
Reference in New Issue