from kivy.app import App
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
import random
Builder.load_string('''
<Row@Label>:
canvas.before:
Color:
rgba: 0.8, 0.1, 0.1, 0.5 #Red Marker
Rectangle:
size: self.size
pos: self.pos
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
font_size: dp(20)
<RV>:
viewclass: 'Row'
RecycleBoxLayout:
default_size: None, dp(20)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
spacing: dp(3)
''')
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
line = ''
for i in range(50):
n = random.randint(0, 1)
if n:
j = random.randint(5, 30)
line = 'Line: ' + str(i+1) + ' This is a test of a bunch of text' * j
else:
line = 'Line: ' + str(i+1) + ' This is a test of a bunch of text'
self.data.append({'text': line})
class TestApp(App):
def build(self):
return RV()
if __name__ == '__main__':
TestApp().run()
The code below forces a texture update, and things are sized properly. It does create a side effect on initial scroll that the list seems to jump.
In a recycle view, the number of widgets is limited to the number you see on the screen, they are recycled. As they are getting reused they are getting resized. I don’t see a clean way around this.
Here are a few things to try:
<Row@Label>:
canvas.before:
Color:
rgba: 0.8, 0.1, 0.1, 0.5 #Red Marker
Rectangle:
size: self.size
pos: self.pos
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
font_size: dp(20)
on_size:
self.texture_update()
self.height = self.texture_size[1]
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/282b64f2-17be-43f3-b049-380dfbd1b821o%40googlegroups.com.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.label import Label
import random
kv = '''
<Row>:
canvas.before:
Color:
rgba: 0.8, 0.1, 0.1, 0.5 #Red Marker
Rectangle:
size: self.size
pos: self.pos
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
font_size: dp(20)
BoxLayout:
orientation: 'vertical'
ScrollView:
do_scroll_x: False
do_scroll_y: True
scroll_type:['bars', 'content']
bar_width: 20
BoxLayout:
orientation: 'vertical'
spacing: dp(3)
id: sv_y
size_hint_y: None
height: self.minimum_height
'''
class Row(Label):
pass
class TestApp(App):
def build(self):
return Builder.load_string(kv)
def on_start(self):
for i in range(200):
n = random.randint(0, 1)
if n:
j = random.randint(5, 30)
line = 'Line: ' + str(i + 1) + ' This is a test of a bunch of text' * j
self.root.ids.sv_y.add_widget(Row(text=line))
else:
line = 'Line: ' + str(i + 1) + ' This is a test of a bunch of text'
self.root.ids.sv_y.add_widget(Row(text=line))
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
import random
Builder.load_string('''
<Row@Label>:
canvas.before:
Color:
rgba: 0.8, 0.1, 0.1, 0.5 #Red Marker
Rectangle:
size: self.size
pos: self.pos
text_size: self.width, None
size_hint_y: None
height: self.texture_size[1]
font_size: dp(18)
markup: True
on_size:
self.texture_update()
self.height = self.texture_size[1]
<RV>:
viewclass: 'Row'
scroll_type: ['bars', 'content']
scroll_wheel_distance: dp(114)
bar_width: dp(10)
RecycleBoxLayout:
default_size: None, dp(20)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
spacing: dp(3)
''')
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
line = ''
for i in range(200):
n = random.randint(0, 1)
if n:
j = random.randint(5, 30)
line = '[color=#ffff00]Line: ' + str(i + 1) + '[/color] This is a test of a bunch of text' * j
else:
line = '[color=#ffff00]Line: ' + str(i + 1) + '[/color] This is a test of a bunch of text'
self.data.append({'text': line})
class TestApp(App):
def build(self):
return RV()
if __name__ == '__main__':
TestApp().run()
😎
From: Ruakuu Kyuzo
Sent: Friday, August 14, 2020 1:15 AM
To: Kivy users support
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/4c29e94b-64cd-4319-aa8d-59f795f4bf4eo%40googlegroups.com.