【发布时间】:2017-08-17 15:09:21
【问题描述】:
我想重新定义 RecycleView(ScrollView) 的 on_touch_down 方法,所以我从Kivy sources 复制了这个方法,但是之后我的应用程序变得非常滞后,几乎停止响应鼠标。这是 Kivy 中的错误还是我做错了什么?删除或注释on_touch_down方法即可解决问题,但我需要重新定义。
Python 3.5,Kivy v1.10.0
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.recycleview import RecycleView
Builder.load_string('''
<RV>:
viewclass: 'Label'
RecycleBoxLayout:
default_size: None, dp(56)
default_size_hint: 1, None
size_hint_y: None
height: self.minimum_height
orientation: 'vertical'
''')
class RV(RecycleView):
def __init__(self, **kwargs):
super(RV, self).__init__(**kwargs)
self.data = [{'text': str(x)} for x in range(100)]
def on_touch_down(self, touch):
if self.dispatch('on_scroll_start', touch):
self._touch = touch
return True
class TestApp(App):
def build(self):
return RV()
if __name__ == '__main__':
TestApp().run()
【问题讨论】: