commit 74c9a05757d1f98263480d6b0ceb2f1c7ddfdbb6
parent c2d3968ebe86692ece6212d70855db7123503127
Author: ThomasV <thomasv@electrum.org>
Date: Wed, 17 Feb 2016 11:40:05 +0100
kivy: add OutputList class
Diffstat:
5 files changed, 45 insertions(+), 29 deletions(-)
diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv
@@ -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))
diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py
@@ -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)
diff --git a/gui/kivy/uix/dialogs/__init__.py b/gui/kivy/uix/dialogs/__init__.py
@@ -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)
+
diff --git a/gui/kivy/uix/dialogs/tx_dialog.py b/gui/kivy/uix/dialogs/tx_dialog.py
@@ -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, ())
diff --git a/lib/transaction.py b/lib/transaction.py
@@ -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