我在我的kv文件中使用了scroll_to函数。它按我的意愿正确滚动,但如果我转动鼠标轮,它将在scroll_to()之前跳回原来的位置。
任何想法,我怎样才能改进我的代码?
我的kv文件片段:
MyButton:
text: 'jump'
on_release: scroll_content.scroll_to(jump_id_2, padding=0, animate=True)
ScrollView:
id: scroll_content
blah, blah, blah.......
# values of the devices
GridLayout:
BoxLayout:
id: jump_id_0
blah, blah, blah.......
BoxLayout:
id: jump_id_1
blah, blah, blah.......
BoxLayout:
id: jump_id_2
blah, blah, blah.......谢谢你的帮助..。
发布于 2016-11-15 10:00:47
我设法找到了一个“解决方案”:基本上您在"content“上设置了scroll_type,然后单击屏幕上的某个地方.
MyButton:
text: 'jump'
on_release: scroll_content.scroll_to(jump_id_2, padding=0, animate=True); app.click(200)
ScrollView:
id: scroll_content
scroll_type: ['content']
blah, blah, blah.......
# values of the devices
GridLayout:
BoxLayout:
id: jump_id_0
blah, blah, blah.......
BoxLayout:
id: jump_id_1
blah, blah, blah.......
BoxLayout:
id: jump_id_2
blah, blah, blah.......其中,单击函数是:
def click(self, shift):
"""Click on the screen."""
pt = POINT()
ctypes.windll.user32.GetCursorPos(ctypes.byref(pt))
ctypes.windll.user32.SetCursorPos(pt.x, pt.y + shift)
ctypes.windll.user32.mouse_event(2, pt.x, pt.y + shift, 0, 0)
ctypes.windll.user32.mouse_event(4, pt.x, pt.y + shift, 0, 0)
ctypes.windll.user32.SetCursorPos(pt.x, pt.y)https://stackoverflow.com/questions/40086368
复制相似问题