Python 滚动到()行为
我正在使用scroll_在我的kv文件中运行。它可以按照我的要求正确滚动,但如果我转动鼠标滚轮,它将跳回原来的位置,然后滚动到() 有什么想法吗?我如何改进我的代码 我的kv文件的snipplet:Python 滚动到()行为,python,kivy,Python,Kivy,我正在使用scroll_在我的kv文件中运行。它可以按照我的要求正确滚动,但如果我转动鼠标滚轮,它将跳回原来的位置,然后滚动到() 有什么想法吗?我如何改进我的代码 我的kv文件的snipplet: MyButton: text: 'jump' on_release: scroll_content.scroll_to(jump_id_2, padding=0, animate=True) ScrollView: id: scroll_content blah,
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.......
感谢您的帮助……我设法找到了一个“解决方案”:基本上您将滚动类型设置为“内容”,
然后点击屏幕上的某个地方
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)
我设法找到了一个“解决方案”:基本上你将滚动类型设置为“内容”,
然后点击屏幕上的某个地方
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)
这是一个bug,在中制造问题。这可能与滚动的新变化有关。这是一个bug,在中制造问题。这可能与滚动的新变化有关。