electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 45b6afe190f5a9c8c143f5b6156673ecf9d6c2d4
parent 4f85615734e782c9ff4ab1c95a96ae22d6d0aa12
Author: Janus <ysangkok@gmail.com>
Date:   Fri, 22 Jun 2018 17:38:58 +0200

kivy: use RecycleView in OutputList

Diffstat:
Mgui/kivy/main.kv | 31++++++++++++++++++++-----------
Mgui/kivy/uix/dialogs/__init__.py | 20+++++++++-----------
Mgui/kivy/uix/dialogs/tx_dialog.py | 10++++------
3 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -114,17 +114,26 @@ <OutputList> - height: self.minimum_height - size_hint_y: None - cols: 1 - spacing: '10dp' - padding: '10dp' - canvas.before: - Color: - rgb: .3, .3, .3 - Rectangle: - size: self.size - pos: self.pos + viewclass: 'OutputItem' + size_hint: 1, None + height: min(output_list_layout.minimum_height, dp(144)) + scroll_type: ['bars', 'content'] + bar_width: dp(15) + RecycleBoxLayout: + orientation: 'vertical' + default_size: None, pt(6) + default_size_hint: 1, None + size_hint: 1, None + height: self.minimum_height + id: output_list_layout + spacing: '10dp' + padding: '10dp' + canvas.before: + Color: + rgb: .3, .3, .3 + Rectangle: + size: self.size + pos: self.pos <RefLabel> font_size: '6pt' diff --git a/gui/kivy/uix/dialogs/__init__.py b/gui/kivy/uix/dialogs/__init__.py @@ -3,6 +3,8 @@ from kivy.clock import Clock from kivy.factory import Factory from kivy.properties import NumericProperty, StringProperty, BooleanProperty from kivy.core.window import Window +from kivy.uix.recycleview import RecycleView +from kivy.uix.boxlayout import BoxLayout from electrum_gui.kivy.i18n import _ @@ -193,25 +195,21 @@ class InfoBubble(Factory.Bubble): -class OutputItem(Factory.BoxLayout): +class OutputItem(BoxLayout): pass -class OutputList(Factory.GridLayout): +class OutputList(RecycleView): def __init__(self, **kwargs): - super(Factory.GridLayout, self).__init__(**kwargs) + super(OutputList, self).__init__(**kwargs) self.app = App.get_running_app() def update(self, outputs): - self.clear_widgets() + res = [] for (type, address, amount) in outputs: - self.add_output(address, amount) - - def add_output(self, address, amount): - b = Factory.OutputItem() - b.address = address - b.value = self.app.format_amount_and_units(amount) - self.add_widget(b) + value = self.app.format_amount_and_units(amount) + res.append({'address': address, 'value': value}) + self.data = res class TopLabel(Factory.Label): diff --git a/gui/kivy/uix/dialogs/tx_dialog.py b/gui/kivy/uix/dialogs/tx_dialog.py @@ -58,16 +58,14 @@ Builder.load_string(''' text: _('Transaction fee') if root.fee_str else '' value: root.fee_str TopLabel: - text: _('Outputs') + ':' - OutputList: - height: self.minimum_height - size_hint: 1, None - id: output_list - TopLabel: text: _('Transaction ID') + ':' if root.tx_hash else '' TxHashLabel: data: root.tx_hash name: _('Transaction ID') + TopLabel: + text: _('Outputs') + ':' + OutputList: + id: output_list Widget: size_hint: 1, 0.1