kivy: use RecycleView in OutputList
This commit is contained in:
@@ -114,17 +114,26 @@
|
|||||||
|
|
||||||
|
|
||||||
<OutputList>
|
<OutputList>
|
||||||
height: self.minimum_height
|
viewclass: 'OutputItem'
|
||||||
size_hint_y: None
|
size_hint: 1, None
|
||||||
cols: 1
|
height: min(output_list_layout.minimum_height, dp(144))
|
||||||
spacing: '10dp'
|
scroll_type: ['bars', 'content']
|
||||||
padding: '10dp'
|
bar_width: dp(15)
|
||||||
canvas.before:
|
RecycleBoxLayout:
|
||||||
Color:
|
orientation: 'vertical'
|
||||||
rgb: .3, .3, .3
|
default_size: None, pt(6)
|
||||||
Rectangle:
|
default_size_hint: 1, None
|
||||||
size: self.size
|
size_hint: 1, None
|
||||||
pos: self.pos
|
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>
|
<RefLabel>
|
||||||
font_size: '6pt'
|
font_size: '6pt'
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user