kivy无法检测到触摸输入

问题描述 投票:0回答:1

我在Ubuntu上安装了kivy,并连接了一个触摸屏,但是当我触摸屏幕时,kivy并没有检测到。

检测鼠标点击是没有问题的,但是触摸就不行了。

我已经在config.ini:`中做了修改。

mouse = mouse; 
mtdev_%(name)s = probesysfs,provider=mtdev; hid_%(name)s = probesysfs,provider=hidinput 

这是我的代码。

from kivy.app import App

从kivy.uix.widget导入Widget。

类TouchInput(Widget)。

def on_touch_down(self, touch):
    print(touch)
def on_touch_move(self, touch):
    print(touch)
def on_touch_up(self, touch):
    print("RELEASED!",touch)

class SimpleKivy4(App):

def build(self):
    return TouchInput()

类简单Kivy4(App): 名称 == "": SimpleKivy4().run()

有谁知道为什么kivy检测不到我的触摸输入?

先谢谢你。

python ubuntu kivy touch
1个回答
0
投票

当你定义了你的 on_touch_*(self, touch) 函数,仅仅定义它是不够的。该 窗口 模块有 on_touch_* 方法,但目前它被绑定为None。是Window模块,而不是你自己的类widgets,它管理着你的应用的整个窗口,调用运动和触摸等回调。在input.motionevent的文档下。它有以下关于如何监听(使用你的回调)motiontouch事件的内容。

def on_touch_down(self, touch):
    # Receives a motion event with the [pos] profile
    pass
Window.bind(on_touch_down=on_touch_down)

你缺少了 Window.bind(window_method=my_function) 呼叫。

© www.soinside.com 2019 - 2024. All rights reserved.