kivy: use RecycleView in OutputList
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -57,17 +57,15 @@ Builder.load_string('''
|
||||
BoxLabel:
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user