Kivy on Raspberry Pi with Touchscreen - double events

215 views
Skip to first unread message

Tom Unger

unread,
Oct 26, 2023, 8:19:06 PM10/26/23
to Kivy users support
I have a fairly simple app with buttons and sliders that works fine when running on a mac and on a raspberry pi in X-windows.  However, when run from the console, accessing the touch screen directly, there are two odd behaviors.

Most importantly, every touch is reported twice.  I have a start-stop button, defined below.  Whenever I touch this, two events are generated.  Same result using on_press or on_release.   

Using a mouse to click on the buttons works fine.  (Disconnecting the mouse does not change the touch screen button behavior).  

        Button:
            text: 'Stop' if root.is_running else 'Start'
            id: start_stop
            size_hint_x: 0.15
            on_press:  root.on_stop() if root.is_running else root.on_start()


Config.ini input section:

[input]
mouse = mouse
%(name)s = probesysfs
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput


secondly, the screen is not drawn until I touch the "start" button.  Or, more accurately, touch where the "start" button would be if it had been drawn.  After touching that part of the blank screen, the screen does get drawn.

What's up?  How do I get this correctly configured?  Thanks.

Tom Unger

unread,
Oct 27, 2023, 2:57:40 PM10/27/23
to Kivy users support
The same problems (double event on button and no drawing until the first touch) happens with example 6_button.py.  I modified it to count the number of "clear" button touches.  

So, it is something about configuration, not my app

from random import random
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.button import Button
from kivy.graphics import Color, Ellipse, Line

clear_count = 0

class MyPaintWidget(Widget):

    def on_touch_down(self, touch):
        color = (random(), 1, 1)
        with self.canvas:
            Color(*color, mode='hsv')
            d = 30.
            Ellipse(pos=(touch.x - d / 2, touch.y - d / 2), size=(d, d))
            touch.ud['line'] = Line(points=(touch.x, touch.y))

    def on_touch_move(self, touch):
        touch.ud['line'].points += [touch.x, touch.y]


class MyPaintApp(App):

    def build(self):
        parent = Widget()
        self.painter = MyPaintWidget()
        clearbtn = Button(text='Clear')
        clearbtn.bind(on_release=self.clear_canvas)
        parent.add_widget(self.painter)
        parent.add_widget(clearbtn)
        return parent

    def clear_canvas(self, obj):
        global clear_count
        clear_count += 1
        print (f"clear {clear_count}")
        self.painter.canvas.clear()


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


ElliotG

unread,
Oct 27, 2023, 4:50:20 PM10/27/23
to Kivy users support
I'm not a raspberry Pi user but searching through the forum I see this thread:  https://groups.google.com/g/kivy-users/c/BDpjv85RNig/m/A9STd59PAgAJ

Hope some of that helps.

```

Tom Unger

unread,
Oct 27, 2023, 5:40:15 PM10/27/23
to Kivy users support
Thanks.  The google discussion came to a resolution of changing the [input] section.  Mine, as installed by `pip install kivy` was as documented but WITH ONE ADDITIONAL LINE, now commented out in the example below:

[input]
; %(name)s = probesysfs
mouse = mouse

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


This eliminated the problem with double events on button press.  HOWEVER, the screen does not get drawn until I press a button.  That is a much less important problem.  I''ll work on it.

elli...@cox.net

unread,
Oct 27, 2023, 6:04:56 PM10/27/23
to kivy-...@googlegroups.com

Good Luck!  Please share what you discover.  It may help another user.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e589be72-0c53-4c97-9e75-7e13306657c1n%40googlegroups.com.

Guillaume Reyserhove

unread,
Dec 3, 2023, 5:16:16 AM12/3/23
to Kivy users support
Hey,

I got the same problem but yout solution dosn't work for me.

Do you have any suggestions ? 

Thank

Reply all
Reply to author
Forward
0 new messages