I have an RPi and official touchscreen running Debian Buster and Kivy v1.11.1
using the simple example at https://kivy.org/doc/stable/api-kivy.event.html it is returning double touch events for button presses.
https://kivy.org/doc/stable/installation/installation-rpi.html (this is just a page describing how to install Kivy on an RPi)
Following the instructions on this page, I have included the follow lines in .kivy/config.ini
mouse = mouse mtdev_%(name)s = probesysfs,provider=mtdev hid_%(name)s = probesysfs,provider=hidinput
removing the mtdev line seems to stop the problem. Is this the correct solution?
mouse = mouse #mtdev_%(name)s = probesysfs,provider=mtdev hid_%(name)s = probesysfs,provider=hidinput
Here is the demo program:
from kivy.app import App from kivy.uix.button import Button from functools import partial class DemoBox(BoxLayout): """ This class demonstrates various techniques that can be used for binding to events. Although parts could me made more optimal, advanced Python concepts are avoided for the sake of readability and clarity. """ def __init__(self, **kwargs): super(DemoBox, self).__init__(**kwargs) self.orientation = "vertical" # We start with binding to a normal event. The only argument # passed to the callback is the object which we have bound to. btn = Button(text="Normal binding to event") btn.bind(on_press=self.on_event) # Next, we bind to a standard property change event. This typically # passes 2 arguments: the object and the value btn2 = Button(text="Normal binding to a property change") btn2.bind(state=self.on_property) # Here we use anonymous functions (a.k.a lambdas) to perform binding. # Their advantage is that you can avoid declaring new functions i.e. # they offer a concise way to "redirect" callbacks. btn3 = Button(text="Using anonymous functions.") btn3.bind(on_press=lambda x: self.on_event(None)) # You can also declare a function that accepts a variable number of # positional and keyword arguments and use introspection to determine # what is being passed in. This is very handy for debugging as well # as function re-use. Here, we use standard event binding to a function # that accepts optional positional and keyword arguments. btn4 = Button(text="Use a flexible function") btn4.bind(on_press=self.on_anything) # Lastly, we show how to use partial functions. They are sometimes # difficult to grasp, but provide a very flexible and powerful way to # reuse functions. btn5 = Button(text="Using partial functions. For hardcores.") btn5.bind(on_press=partial(self.on_anything, "1", "2", monthy="python")) for but in [btn, btn2, btn3, btn4, btn5]: self.add_widget(but) def on_event(self, obj): print("Typical event from", obj) def on_property(self, obj, value): print("Typical property change from", obj, "to", value) def on_anything(self, *args, **kwargs): print('The flexible function has *args of', str(args), "and **kwargs of", str(kwargs)) class DemoApp(App): def build(self): return DemoBox() if __name__ == "__main__": DemoApp().run()