Browse Source

kivy: use RecycleView in OutputList

master
Janus 8 years ago
parent
commit
45b6afe190
  1. 13
      gui/kivy/main.kv
  2. 20
      gui/kivy/uix/dialogs/__init__.py
  3. 10
      gui/kivy/uix/dialogs/tx_dialog.py

13
gui/kivy/main.kv

@ -114,9 +114,18 @@
<OutputList> <OutputList>
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 height: self.minimum_height
size_hint_y: None id: output_list_layout
cols: 1
spacing: '10dp' spacing: '10dp'
padding: '10dp' padding: '10dp'
canvas.before: canvas.before:

20
gui/kivy/uix/dialogs/__init__.py

@ -3,6 +3,8 @@ from kivy.clock import Clock
from kivy.factory import Factory from kivy.factory import Factory
from kivy.properties import NumericProperty, StringProperty, BooleanProperty from kivy.properties import NumericProperty, StringProperty, BooleanProperty
from kivy.core.window import Window from kivy.core.window import Window
from kivy.uix.recycleview import RecycleView
from kivy.uix.boxlayout import BoxLayout
from electrum_gui.kivy.i18n import _ from electrum_gui.kivy.i18n import _
@ -193,25 +195,21 @@ class InfoBubble(Factory.Bubble):
class OutputItem(Factory.BoxLayout): class OutputItem(BoxLayout):
pass pass
class OutputList(Factory.GridLayout): class OutputList(RecycleView):
def __init__(self, **kwargs): def __init__(self, **kwargs):
super(Factory.GridLayout, self).__init__(**kwargs) super(OutputList, self).__init__(**kwargs)
self.app = App.get_running_app() self.app = App.get_running_app()
def update(self, outputs): def update(self, outputs):
self.clear_widgets() res = []
for (type, address, amount) in outputs: for (type, address, amount) in outputs:
self.add_output(address, amount) value = self.app.format_amount_and_units(amount)
res.append({'address': address, 'value': value})
def add_output(self, address, amount): self.data = res
b = Factory.OutputItem()
b.address = address
b.value = self.app.format_amount_and_units(amount)
self.add_widget(b)
class TopLabel(Factory.Label): class TopLabel(Factory.Label):

10
gui/kivy/uix/dialogs/tx_dialog.py

@ -57,17 +57,15 @@ Builder.load_string('''
BoxLabel: BoxLabel:
text: _('Transaction fee') if root.fee_str else '' text: _('Transaction fee') if root.fee_str else ''
value: root.fee_str value: root.fee_str
TopLabel:
text: _('Outputs') + ':'
OutputList:
height: self.minimum_height
size_hint: 1, None
id: output_list
TopLabel: TopLabel:
text: _('Transaction ID') + ':' if root.tx_hash else '' text: _('Transaction ID') + ':' if root.tx_hash else ''
TxHashLabel: TxHashLabel:
data: root.tx_hash data: root.tx_hash
name: _('Transaction ID') name: _('Transaction ID')
TopLabel:
text: _('Outputs') + ':'
OutputList:
id: output_list
Widget: Widget:
size_hint: 1, 0.1 size_hint: 1, 0.1

Loading…
Cancel
Save