39

Why does the first widget example in kivy lead to an orange circle in the middle of the yellow one when you right click on the canvas and a pure yellow one when you left click?

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Ellipse

class MyPaintWidget(Widget):
    def on_touch_down(self, touch):
        with self.canvas:
            Color(1, 1, 0)
            d = 30.
            Ellipse(pos=(touch.x - d/2, touch.y - d/2), size=(d, d))


class MyPaintApp(App):
    def build(self):
        return MyPaintWidget()


if __name__ == '__main__':
    MyPaintApp().run()
1
  • This definitely freaked me out when I first saw it, had no idea why a Button would do that. Never worked with a touch-based library before.
    – John C
    Mar 29, 2021 at 17:01

2 Answers 2

39

To disable multi-touch emulation, add this to your source file containing your main function, before any other kivy modules are imported:

from kivy.config import Config
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
1
  • 1
    As far I can tell, it's not necessary to do this before other kivy modules are imported. I did your Config.set[...] command after all my imports and it worked fine.
    – Asker
    Aug 14, 2020 at 3:12
15

It's multitouch emulation, you can see how to disable it here

http://kivy.org/docs/api-kivy.input.providers.mouse.html

3
  • 5
    (1) You can clear them by left clicking and re-setting a new simulated multi-touch. (2) You can set more than one. (3) Look at the Kivy examples/demo/pictures sample for a great example utilizing multi-touch emulation.
    – Mark
    Dec 31, 2012 at 7:15
  • 2
    Link-only answers really aren't considered good practice (as you probably NOW know). Please summarize the contents in your answer. Jul 22, 2017 at 21:14
  • This works on Windows, but causes problems on Android. Here's the exception I get if I try to open a DropDown sub class menu: raise WidgetException( [WARNING] stderr: kivy.uix.widget.WidgetException: Cannot add <gui.customdropdown.CustomDropDown object at 0x7aaf231d60> to window, it already has a parent <kivy.core.window.window_sdl2.WindowSDL object at 0x7ab1290f40> Sep 29, 2021 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.