首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >KIVY:我怎样才能得到基维的卷轴方向?

KIVY:我怎样才能得到基维的卷轴方向?
EN

Stack Overflow用户
提问于 2020-05-28 18:18:57
回答 1查看 79关注 0票数 0

我找到了一段代码:

代码语言:javascript
复制
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.boxlayout import BoxLayout


class Test(BoxLayout):
    def __init__(self, **kwargs):
        super(Test, self).__init__(**kwargs)
        Window.bind(on_touch_down=self.window_on_touch_down)

    def window_on_touch_down(self, *args):
        print(args)
        # scrolling the wheel down will give <MouseMotionEvent button="scrollup"

        if '<MouseMotionEvent button="scrollup"' in args:
            print('hello')


class TestApp(App):
    def build(self):
        return Test()

if __name__ == '__main__':
    TestApp().run()

当它打印滚动运动时,我不能用它.args里面有字符串,但是if不起作用,"hello“也没有打印出来.有人知道为什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-05-28 19:36:14

您在打印中看到的是python对象,而不是字符串。

所以你不能只检查一根绳子。

获取所需内容的更好方法是检查哪个按钮生成MouseMotionEvent

代码语言:javascript
复制
    def window_on_touch_down(self, window, mouse_event):
        # scrolling the wheel down will give <MouseMotionEvent button="scrollup"
        if mouse_event.button == "scrollup":
            print('hello')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62071786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档